Jasmine is a behavior-driven development (BDD) framework for testing JavaScript code. Jasmine has no external dependencies and does not require a DOM.
Jasmine is a stand-alone behavior-driven development (bdd) framework used for unit-testing of javascript code.
Jasmine tests are broken up into describe
and it
statements. describe
is used to denote the start of a test suite and it
is used to denote the start of a particular test. expect
statements are then used to outline the conditions under which a test should pass.
beforeEach
and afterEach
are some other frequently used blocks. beforeEach
is used to run some code before each test. Something like loading a module. Similarly afterEach
is used to run some code after each test. Running some cleanup code for instance.
Jasmine DOM Testing
If you want to write unit tests for code that does a lot of DOM interactions using jQuery, consider using jasmine-jquery. Jasmine-jQuery offers interacting with dummy HTML through HTML fixtures.