Some usefule jasmine terms and its wiki pages

1 Suites and specs

 

1.1 Specs

Each spec is, naturally, a JavaScript function. You tell Jasmine about a spec with a call to it() with a description string and the function. The string is a description of a behavior that you want your production code to exhibit; it should be meaningful to you when reading a report.

it('should increment a variable', function () {
  var foo = 0;
  foo++;
});

1.2 Suites

Specs are grouped in Suites. Suites are defined using the global describe() function:

describe('Calculator', function () {
  it('can add a number', function () {
  ...
  });

  it('can multiply some numbers', function () {
  ...
  });
});

1.3 Disabling Tests & Suites

Specs may be disabled by calling xit() instead of it(). Suites may be disabled by calling xdescribe() instead of describe().

2 Matchers

Jasmine has several built-in matchers. Here are a few:

3 Spies

Jasmine integrates 'spies' that permit many spying, mocking, and faking behaviors. A 'spy' replaces the function it is spying on.

4 Before and After

A suite can have a beforeEach() declaration. It takes a function that is run before each spec.


By POST:  Jalen Wang  ( please indicate the source )

Reproduced in: https: //www.cnblogs.com/jalenwang/archive/2012/03/06/2382625.html

Guess you like

Origin blog.csdn.net/weixin_33704234/article/details/93414606