wait-for-expect
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "wait-for-expect", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Wait for expectation to be true, useful for integration and end to end testing", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -0,1 +1,4 @@ | ||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) | ||
[![CircleCI](https://circleci.com/gh/TheBrainFamily/wait-for-expect.svg?style=shield)](https://circleci.com/gh/TheBrainFamily/wait-for-expect) | ||
# wait-for-expect | ||
@@ -8,2 +11,3 @@ Wait for expectation to be true, useful for integration and end to end testing | ||
const waitForExpect = require("wait-for-expect") | ||
let numberToChange = 10; | ||
@@ -31,2 +35,3 @@ | ||
}, 600); | ||
setTimeout(() => { | ||
@@ -75,1 +80,18 @@ expect(numberToChange).toEqual(100); | ||
``` | ||
# API | ||
waitForExpect takes 3 arguments, 2 optional. | ||
```javascript | ||
/** | ||
* Waits for predicate to not throw and returns a Promise | ||
* | ||
* @param expectation Function Predicate that has to complete without throwing | ||
* @param timeout Number Maximum wait interval, 4500ms by default | ||
* @param interval Number Wait interval, 50ms by default | ||
* @return Promise Promise to return a callback result | ||
*/ | ||
``` | ||
## Credit | ||
Based on ideas from https://github.com/devlato/waitUntil - mostly build around it with functionality nice for testing. Couldn't depend on it internally because I wanted to add the flushPromises and run the initial expectations right after flushing them, which had to be done in the tool itself :) otherwise tests that should be taking few ms would take all >50ms in the default situation. It might seem trivial but with 100 tests times 45 ms extra your tests would start taking 4.5 seconds instead of 0.5 s :) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7471
95