JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 117
  • Score
    100M100P100Q81850F
  • License Apache License Version 2.0,

Jasmine matchers for testing ES6 Promises

Package Exports

  • jasmine-es6-promise-matchers

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jasmine-es6-promise-matchers) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Jasmine Promise Matchers

Custom matchers for use with the ES6Promise polyfill library and Jasmine 2.x.

Installing

npm install jasmine-es6-promise-matchers

...or...

bower install jasmine-es6-promise-matchers

Documentation

Testing promises should be simple. This library aims to make it so!

Initializing the library

To use it, just install the library before your tests begin:

beforeEach(function() {
  // `true` automatically ticks the Jasmine mock-clock for you after each assert.
  // `false` leaves the clock management up to you.
  // I recommend `true` unless your test involves other timing concerns.
  JasminePromisMatchers.install(true);
});

And uninstall it once your tests are over:

afterEach(function() {
  JasminePromisMatchers.uninstall();
});

Now you're ready to start testing!

Jasmine matchers

toBeRejected

Verify that a Promise is rejected!

expect(promise).toBeRejected();
toBeRejectedWith

Verify that a Promise is rejected with a specific value:

expect(promise).toBeRejectedWith('something');
toBeResolved

Verify that a Promise is resolved!

expect(promise).toBeResolved();
toBeResolvedWith

Verify that a Promise is resolved with a specific value:

expect(promise).toBeResolvedWith('something');

Questions? Suggestions?

Open an issue or toss up a pull request if you'd like to see anything added to this library!