jasmine-async-test

0.0.1 • Public • Published

jasmine-async-test

Simple helper function for writing asynchronous tests in Jasmine. Eliminate calling the done callback in asynchronous tests by wrapping your test function in asyncTest. Your test function must return a promise.

Usage

Functions that return promises:

import Promise from 'bluebird';
import asyncTest from 'jasmine-async-test';
 
describe('asynchronous testing', () => {
  it('runs async tests', asyncTest(() => {
    return new Promise(resolve => {
      expect(2 + 2).toEqual(4);
      setTimeout(resolve, 1000);
    });
  }));
});

ES2016 async/await functions:

import asyncTest from 'jasmine-async-test';
 
describe('asynchronous testing', () => {
  it('works with async/await', asyncTest(async function() {
    const data = await fetchSomeData();
    expect(data).toBe(42);
  }));
});

Package Sidebar

Install

npm i jasmine-async-test

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • elpapapollo