@mfl/jasmine-n-matchers

2.1.1 • Public • Published

jasmine-n-matchers

Build Status

A set of matchers to assert a spy was called n times

The 2.0.0 release supports Jasmine 2.0. Everything earlier is for Jasmine 1.3.

Usage

Make sure the jasmine-n-matchers.js file is executed early in your tests, it uses beforeEach to register the matchers.

Example

var spy = jasmine.createSpy('spy');

expect(spy).toHaveBeenCalledNTimes(0);

spy('foo', 'bar');

expect(spy).toHaveBeenCalledNTimes(1);
expect(spy).toHaveBeenCalledOnce();
expect(spy).toHaveBeenCalledOnceWith('foo', 'bar');

spy('foo', 'bar');

expect(spy).toHaveBeenCalledNTimes(2);
expect(spy).toHaveBeenCalledTwice();
expect(spy).toHaveBeenCalledTwiceWith('foo', 'bar');

spy('bar', 'baz');

expect(spy).toHaveBeenCalledNTimes(3);
expect(spy).toHaveBeenCalledThrice();
expect(spy).toHaveBeenCalledTwiceWith('foo', 'bar');
expect(spy).toHaveBeenCalledOnceWith('bar', 'baz');

spy('foo', 'bar');
spy('foo', 'bar');

expect(spy).toHaveBeenCalledNTimes(5);
expect(spy).toHaveBeenCalledNTimesWith(4, 'foo', 'bar');

Readme

Keywords

none

Package Sidebar

Install

npm i @mfl/jasmine-n-matchers

Weekly Downloads

0

Version

2.1.1

License

MIT

Last publish

Collaborators

  • jgrund
  • johnsonw
  • manager-for-lustre