jasmine-async-utilities

1.0.1 • Public • Published

npm version

jasmine-async-utilities

Usage

describe('test suite', () => {
  const utilities = require('jasmine-async-utilities');
  const asyncTest = utilities.asyncTest;
  const shouldResolve = utilities.shouldResolve;
  const shouldReject = utilities.shouldReject;

shouldResolve is used for tests where the code under test should resolve, with or without a value. asyncTest will automatically call jasmine.fail with any unexpected rejection.

  it('resolve test', asyncTest(() => {
    return shouldResolve(() => return Promise.resolve(3.14), 3.14);
  }));

shouldReject is used for tests where the code under test should reject, with or without a value. shouldReject will automatically call jasmine.fail if the code under test resolves.

  it('reject with string test', asyncTest(() => {
    return shouldReject(() => return Promise.reject('oh noes!'), 'oh noes!');
  }));
  it('reject with Error test', asyncTest(() => {
    return shouldReject(() => return Promise.reject(new Error('oh noes!')), new Error('oh noes!');
  }));
});

See the tests for more examples.

Documentation

Readme

Keywords

none

Package Sidebar

Install

npm i jasmine-async-utilities

Weekly Downloads

89

Version

1.0.1

License

ISC

Last publish

Collaborators

  • h2oboi89