Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jfairbank/jasmine-async-test
Simple helper function for writing asynchronous tests in Jasmine
https://github.com/jfairbank/jasmine-async-test
Last synced: 6 days ago
JSON representation
Simple helper function for writing asynchronous tests in Jasmine
- Host: GitHub
- URL: https://github.com/jfairbank/jasmine-async-test
- Owner: jfairbank
- License: mit
- Created: 2015-11-17T18:46:04.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-17T21:27:52.000Z (almost 9 years ago)
- Last Synced: 2024-09-14T13:27:16.654Z (19 days ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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.## Install
$ npm install jasmine-async-test
## Usage
**Functions that return promises:**
```js
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:**
```js
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);
}));
});
```