expect-async
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

expect-async

expect-async is a wrapper for expect that allows for use in asynchronous tests.

var createExpect = require('expect-async').createExpect;

it('should open a file that contains "foo"', function(done) {
    //A test fails if an argument is passed to 'done'.
    var expect = createExpect(done);

    fs.readFile('file.txt', 'utf8', function(err, data) {
        expect(err).toNotExist();
        expect(data).toBe('foo');

        done();
    });
});

Usage

createExpect(reject)

Params

reject: A function that accepts an Error argument. Will be called when an expectation fails.

Returns

An expect object that behaves like expect. When an expectation fails, reject will be called before an exception is thrown.

Readme

Keywords

none

Package Sidebar

Install

npm i expect-async

Weekly Downloads

4

Version

0.1.2

License

MIT

Last publish

Collaborators

  • youngspe