December 2015
Intermediate to advanced
240 pages
4h 57m
English
Just like other frameworks, Jasmine also provides a way to set up and tear down. Jasmine provides global functions such as beforeEach—called before each spec, afterEach—called after each spec, beforeAll—called only once before all specs are run, and afterAll—called only once after all specs are done. Look at the following code to understand this:
describe("Setup and Teardown", function() { var count = 0; var velocity = 0; beforeEach(function() { velocity = 100; count++; console.log("Count is "+ count); }); afterEach(function() { velocity = 0; console.log("Some spec just finished and this function is called"); }); beforeAll(function(){ console.log("This is called only once, specs are about to run."); }); afterAll(function(){ ...Read now
Unlock full access