Jasmine (software)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Jezmck (talk | contribs) at 14:05, 5 April 2016 (→‎Usage: Define `helloWorld()` function rather than assume its content.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Jasmine
Developer(s)Pivotal Labs
Initial releaseSeptember 14, 2010; 13 years ago (2010-09-14)[1]
Stable release
2.3
Repository
Written inJavaScript
Operating systemCross-platform
TypeUnit Test
LicenseMIT License
Websitehttp://jasmine.github.io/

Jasmine is an open source testing framework for JavaScript.[2] It aims to run on any JavaScript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. It is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec.[3]

Usage

Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name "it()" follows the idea of behavior-driven development and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of RSpec.

The code below tests this function

function helloWorld() {
  return 'Hello world!';
}

and verifies that its output is indeed the text "Hello world!".

describe('Hello world', function() {
  it('says hello', function() {
    expect(helloWorld()).toEqual('Hello world!');
  });
});

Jasmine has a number of other features, such as custom matchers, spies, and support for asynchronous specifications.

History

The developers at Pivotal Labs for Jasmine previously developed a similar unit testing framework called JsUnit before active development of Jasmine.[4]

See also

References

  1. ^ Davis W. Frank. "Jasmine 1.0 Released". Pivotal Labs. Retrieved 11 February 2014.
  2. ^ http://jasmine.github.io/
  3. ^ https://github.com/pivotal/jasmine/wiki/Background
  4. ^ Github JsUnit Project Page

External links