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