Jasmine (JavaScript)
Jasmine Core
|
|
---|---|
Jasmine 2 in the self-test |
|
Basic data
|
|
developer | Pivotal Labs (EMC Corporation) |
Publishing year | August 12, 2009 |
Current version |
3.6.0 ( July 23, 2020 ) |
operating system | platform independent |
programming language | JavaScript |
category | Module test |
License | MIT license ( free software ) |
German speaking | No |
jasmine.github.io |
Jasmine (Jasmine Core) is a free module test - Library for JavaScript . Jasmine can be executed on any JavaScript-enabled platform (especially without a web browser or Document Object Model ) and does not require any adaptation of the test system ( System Under Test ). The very simple test description language is based on the test case notation of Behavior Driven Development (BDD). Other module test libraries such as ScrewUnit, JSSpec, JSpec and RSpec had a major influence on the development.
commitment
Jasmine tests should be easy to read. A simple hello world test looks like the source code below, with describe () describing a test scenario and it () a single test case . In the BDD sense, it () designates the test system and, as subject, together with the test name, should form a complete ( English ) sentence that describes the test case.
describe('Hallo Welt!', function () {
it('says hello', function () {
expect(helloWorld()).toEqual('Hallo Welt!');
});
it('does not save the world', function () {
expect(helloWorld())
.not.toBe('Rettung der Welt!');
});
});
Conditions are expressed by comparison functions (matchers) such as expect ( expression ) .toEqual ( test value ) , … toBeTruthy () , … toBeGreaterThan (7.5) or … toBeDefined () . For more complex test scenarios, describe () expressions are nested. Expected function calls and their signature can be stored with the help of spies: expect ( Object.Function ) .toHaveBeenCalledWith ( parameter list ) . These can be replaced by stubs or mock objects or observation functions can be injected.
Further functionalities of Jasmine include time tracking and asynchronous function calls. To ensure the independence of individual tests, the test execution sequence can be determined randomly.
See also
Individual evidence
- ↑ Release 3.6.0 . July 23, 2020 (accessed July 24, 2020).
- ↑ Terin Jokes et al. a .: Background. Why Another JavaScript TDD / BDD Framework? August 22, 2012, accessed February 1, 2014 .
Web links
- Official Jasmine website
- Jasmine on GitHub
- Chutzpah. Retrieved June 25, 2013 (JavaScript / Typescript Test Runner for Visual Studio).
- Jasmine-jQuery. Retrieved June 25, 2013 (jQuery extension for Jasmine).
- Jasmine fixture. Retrieved June 25, 2013 (HTML fixtures for Jasmine).