Jasmine (JavaScript framework)

Jasmine ( Jasmine Core ) is a free unit testing library for JavaScript. Jasmine is executable on any JavaScript-capable platform (especially without a web browser or Document Object Model ) and requires no adjustment of the test system (System Under Test). The very basic test description language modeled on the test case notation of Behavior Driven Development ( BDD). Great influence on the development had other unit test libraries like ScrewUnit, JSSpec, JSpec and RSpec.

Use

Jasmine testing should be easy to read. A simple hello world test looks like the source code below, which describe () describes a test scenario and it ( ) a single test case. In the BDD sense, refers it ( ) the test system and is as subject along with the test name form a complete ( English ) sentence describing the test case.

Describe ( 'Hello world! ', function () {    it ( ' says hello ', function () {     . expect ( hello world ()) toEqual ( 'Hello world! ');    });      it ( 'does not save the world ', function () {      expect ( hello world ())       . not.toBe ( ' saving the world ');    }); }); Conditions are expressed by comparison functions ( matchers ) as expect (expression). ToEqual ( test value ), ... toBeTruthy (), ... toBeGreaterThan (7.5) or ... toBeDefined (). For more complex test scenarios describe () expressions are nested. Use of Spies ( Spies) can be deposited expected function calls and their signature. Expect ( Objekt.Funktion ) toHaveBeenCalledWith (parameter list). It can be replaced by stubs or mock objects or observation capabilities are injected.

Further functionalities of Jasmine include the time trace and asynchronous function calls.

431780
de