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 no npm install needed!

<script type="module">
  import jasmineAsyncTest from 'https://cdn.skypack.dev/jasmine-async-test';
</script>

README

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);
  }));
});