Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wait-for-expect

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wait-for-expect - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

circle.yml

2

package.json
{
"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 :)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc