Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maty21/async-done
a simple library that allows you to run async unit tests(in libraries like mocha or jest) and call done()
https://github.com/maty21/async-done
Last synced: about 2 months ago
JSON representation
a simple library that allows you to run async unit tests(in libraries like mocha or jest) and call done()
- Host: GitHub
- URL: https://github.com/maty21/async-done
- Owner: maty21
- Created: 2017-09-28T13:42:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-05T10:22:18.000Z (about 7 years ago)
- Last Synced: 2024-11-13T03:16:34.480Z (2 months ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# await-done
a simple semaphore library that allows you to run async unit tests(in libraries like mocha or jest) and call done()
### installation
```
npm install await-done```
### usage sample
using simple function
```js
const { callDone, done, semaphore } = require('../lib/async-done');
let counter = 0
it('should-call-once', async () => {
setInterval(() => {
console.log(`counter:${counter}`) //counter:1
callDone()
}, 100);
await done();}).timeout(1000);
```
it is possible to set the amount until a wait done will be called
```jslet counter = 0
it('should-call-once', async () => {
setInterval(() => {
console.log(`counter:${counter}`) //counter:1 counter:2
callDone()
counter = counter+1;
}, 100);
await done({ doneAmount: 2 });}).timeout(1000);
```
or by creating a new instance
```js
it('should-call-once with new instance', async () => {
const _semaphore = new semaphore();setTimeout(() => _semaphore.callDone(), 100);
await _semaphore.done();}).timeout(1000);
```