{"id":21062138,"url":"https://github.com/jcoreio/chai-wait-for","last_synced_at":"2025-06-30T22:35:30.813Z","repository":{"id":57196646,"uuid":"322417557","full_name":"jcoreio/chai-wait-for","owner":"jcoreio","description":"poll until an assertion succeeds","archived":false,"fork":false,"pushed_at":"2025-02-27T21:33:17.000Z","size":962,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-23T22:04:39.917Z","etag":null,"topics":["assertion","async","async-await","await","chai","poll","retry","wait"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcoreio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-12-17T21:29:27.000Z","updated_at":"2025-02-27T21:32:46.000Z","dependencies_parsed_at":"2024-10-18T16:04:39.984Z","dependency_job_id":"593928d0-53c8-4a79-b553-37846848726d","html_url":"https://github.com/jcoreio/chai-wait-for","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/jcoreio/chai-wait-for","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Fchai-wait-for","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Fchai-wait-for/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Fchai-wait-for/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Fchai-wait-for/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcoreio","download_url":"https://codeload.github.com/jcoreio/chai-wait-for/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Fchai-wait-for/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262419826,"owners_count":23308103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertion","async","async-await","await","chai","poll","retry","wait"],"created_at":"2024-11-19T17:37:27.852Z","updated_at":"2025-06-30T22:35:30.771Z","avatar_url":"https://github.com/jcoreio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chai-wait-for\n\n[![CircleCI](https://circleci.com/gh/jcoreio/chai-wait-for.svg?style=svg)](https://circleci.com/gh/jcoreio/chai-wait-for)\n[![Coverage Status](https://codecov.io/gh/jcoreio/chai-wait-for/branch/master/graph/badge.svg)](https://codecov.io/gh/jcoreio/chai-wait-for)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![npm version](https://badge.fury.io/js/chai-wait-for.svg)](https://badge.fury.io/js/chai-wait-for)\n\nDrop-in replacement for `expect` that waits for the assertion to succeed (retries on an interval you choose, until a timeout\nyou choose).\n\nProvides an especially clean syntax for working with some chai plugins like `chai-fs`, `chai-webdriverio-async` etc:\n\n```js\nawait waitFor('#submittedMessage').to.have.text('Your changes have been saved!')\n```\n\n# Usage\n\n```sh\nnpm install --save-dev chai-wait-for\n```\n\n```js\n// First, use the plugin\nconst chai = require('chai')\nconst chaiWaitFor = require('chai-wait-for')\nconst { afterEach } = require('mocha')\nchai.use(chaiWaitFor)\n\n// Then create your `waitFor` with default options:\nconst waitFor = chaiWaitFor.bindWaitFor({\n  // If no assertion attempt succeeds before this time elapses (in milliseconds), the waitFor will fail.\n  timeout: 5000,\n  // If an assertion attempt fails, it will retry after this amount of time (in milliseconds)\n  retryInterval: 100,\n  // this is optional, but asserts that you didn't forget to await any waitFor() calls\n  failOnDanglingCalls: afterEach,\n})\n\nit('wait for something', async function () {\n  this.timeout(10000)\n\n  const myObj = { foo: 0 }\n\n  setInterval(() =\u003e myObj.foo++, 1000)\n\n  // Then use it just like you would expect() (but note you must await it!)\n  await waitFor(myObj).to.have.property('foo').that.equals(3)\n\n  // You can also use a getter function:\n  await waitFor(() =\u003e myObj.foo).to.equal(4)\n\n  // If you need to override the defaults:\n  await waitFor.timeout(1000)(myObj).to.have.property('foo').that.equals(3)\n  await waitFor.retryInterval(500)(myObj).to.have.property('foo').that.equals(3)\n})\n```\n\n# Plugin usage order/usage with `chai-as-promised`\n\nAll `chai` language chains that were defined before you use `chai-wait-for` will be available to use with it.\n\nThis is similar to `chai-as-promsied`, but although you generally need to `chai.use(require('chai-as-promised'))` after\nall your other chai plugins, this is actually not the case for `chai-wait-for`, because `chai-wait-for` doesn't add or\noverwrite any language chains.\nInstead you should use `chai-wait-for` after `chai-as-promised`, so that you can `waitFor` `.eventually` assertions:\n\n```js\nconst chai = require('chai')\nconst chaiWaitFor = require('chai-wait-for')\nchai.use(require('chai-as-promised'))\nchai.use(chaiWaitFor)\n\nconst waitFor = chaiWaitFor.bindWaitFor({ retryInterval: 100, timeout: 5000 })\n\nit('wait for something', async function () {\n  // User.findOne returns a promise; use .eventually.not.exist to wait for user to be deleted\n  await waitFor(() =\u003e User.findOne({ where: { username: 'dude' } })).to\n    .eventually.not.exist\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcoreio%2Fchai-wait-for","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcoreio%2Fchai-wait-for","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcoreio%2Fchai-wait-for/lists"}