Installations
npm install chai-wait-for
Developer Guide
Typescript
Yes
Module System
CommonJS, ESM
Min. Node Version
>=16
Node Version
20.10.0
NPM Version
10.2.3
Score
72.3
Supply Chain
93.1
Quality
79
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (98.32%)
TypeScript (1.68%)
Developer
jcoreio
Download Statistics
Total Downloads
370,468
Last Day
22
Last Week
3,285
Last Month
17,574
Last Year
216,880
GitHub Statistics
2 Stars
250 Commits
3 Watching
1 Branches
2 Contributors
Bundle Size
67.93 kB
Minified
16.95 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.0.3
Package Id
chai-wait-for@2.0.3
Unpacked Size
15.50 kB
Size
4.78 kB
File Count
5
NPM Version
10.2.3
Node Version
20.10.0
Publised On
16 Oct 2024
Total Downloads
Cumulative downloads
Total Downloads
370,468
Last day
-43.6%
22
Compared to previous day
Last week
-4.1%
3,285
Compared to previous week
Last month
-43.5%
17,574
Compared to previous month
Last year
89.5%
216,880
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
chai-wait-for
Drop-in replacement for expect
that waits for the assertion to succeed (retries on an interval you choose, until a timeout
you choose).
Provides an especially clean syntax for working with some chai plugins like chai-fs
, chai-webdriverio-async
etc:
1await waitFor('#submittedMessage').to.have.text('Your changes have been saved!')
Usage
1npm install --save-dev chai-wait-for
1// First, use the plugin 2const chai = require('chai') 3const chaiWaitFor = require('chai-wait-for') 4chai.use(chaiWaitFor) 5 6// Then create your `waitFor` with default options: 7const waitFor = chaiWaitFor.bindWaitFor({ 8 // If no assertion attempt succeeds before this time elapses (in milliseconds), the waitFor will fail. 9 timeout: 5000, 10 // If an assertion attempt fails, it will retry after this amount of time (in milliseconds) 11 retryInterval: 100, 12}) 13 14it('wait for something', async function () { 15 this.timeout(10000) 16 17 const myObj = { foo: 0 } 18 19 setInterval(() => myObj.foo++, 1000) 20 21 // Then use it just like you would expect() (but note you must await it!) 22 await waitFor(myObj).to.have.property('foo').that.equals(3) 23 24 // You can also use a getter function: 25 await waitFor(() => myObj.foo).to.equal(4) 26 27 // If you need to override the defaults: 28 await waitFor.timeout(1000)(myObj).to.have.property('foo').that.equals(3) 29 await waitFor.retryInterval(500)(myObj).to.have.property('foo').that.equals(3) 30})
Plugin usage order/usage with chai-as-promised
All chai
language chains that were defined before you use chai-wait-for
will be available to use with it.
This is similar to chai-as-promsied
, but although you generally need to chai.use(require('chai-as-promised'))
after
all your other chai plugins, this is actually not the case for chai-wait-for
, because chai-wait-for
doesn't add or
overwrite any language chains.
Instead you should use chai-wait-for
after chai-as-promised
, so that you can waitFor
.eventually
assertions:
1const chai = require('chai') 2const chaiWaitFor = require('chai-wait-for') 3chai.use(require('chai-as-promised')) 4chai.use(chaiWaitFor) 5 6const waitFor = chaiWaitFor.bindWaitFor({ retryInterval: 100, timeout: 5000 }) 7 8it('wait for something', async function () { 9 // User.findOne returns a promise; use .eventually.not.exist to wait for user to be deleted 10 await waitFor(() => User.findOne({ where: { username: 'dude' } })).to 11 .eventually.not.exist 12})
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.md:0
Reason
5 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
Reason
1 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 2
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.7
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to chai-wait-for
wait-for-throwable
Simple utility to retry an erroring function until it succeeds
@womorg/totam-expedita-quas
> Build tool and bindings loader for [`node-gyp`][node-gyp] that supports prebuilds.
@teamteanpm2024/voluptate-sequi-enim
**_Node.js core streams for userland_**
@hishprorg/blanditiis-tenetur
NodeJS implementation (written in TypeScript) of core models for the Readium2 architecture ( https://github.com/readium/architecture/ ).