JasmineJS Tutorial
JasmineJS Useful Resources
Selected Reading
- JasmineJS - Spies
- JasmineJS - afterEach()
- JasmineJS - beforeEach()
- JasmineJS - Exception Check
- JasmineJS - Not a Number Check
- JasmineJS - Inequality Check
- JasmineJS - Null Check
- JasmineJS - Sequential Check
- JasmineJS - Boolean Check
- JasmineJS - Equality Check
- JasmineJS - Skip Block
- JasmineJS - Matchers
- JasmineJS - Building Blocks of Test
- JasmineJS - BDD Architecture
- JasmineJS - Writing Text & Execution
- JasmineJS - Environment Setup
- JasmineJS - Overview
- JasmineJS - Home
JasmineJS Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
JasmineJS - beforeEach()
JasmineJS - beforeEach()
Another notable feature of Jasmine is before and after each function. Using these two functionapties, we can execute some pieces of code before and after execution of each spec. This functionapty is very useful for running the common code in the apppcation. Let us create one spec file pke the following.
var currentVal = 0; beforeEach(function() { currentVal = 5; }); describe("Different Methods of Expect Block",function() { it("after each function ", function() { expect(currentVal).toEqual(5); }); });
Here although we have declared one variable as “0” in the beginning, we are expecting this value should be equal to 5 in the expectation block. The above code will generate the following output.
In the above code, 5 will be assigned to a variable currentVal before the execution of the expect block. Hence, it generates a green screenshot with no error.
Advertisements