Skip to content

feat(vitest): support vi.waitFor method - #4113

Merged
sheremet-va merged 18 commits into
vitest-dev:mainfrom
Dunqing:feat/wait-for
Sep 14, 2023
Merged

sheremet-va merged 18 commits into
vitest-dev:mainfrom
Dunqing:feat/wait-for

Conversation

@Dunqing

@Dunqing Dunqing commented Sep 12, 2023

Copy link
Copy Markdown
Member

Description

Partial closes - #4061

The waitFor function was inspired by testing-library/web-testing-library#2.

Currently only supports timeout and interval options. I think this is enough, Let me know if you need to add any other options!

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@bolt-new-by-stackblitz

ghost commented Sep 12, 2023

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify

ghost commented Sep 12, 2023

Copy link
Copy Markdown

Deploy Preview for fastidious-cascaron-4ded94 ready!

Name Link
🔨 Latest commit dfeefe7
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/65016c6aa31a8a0008824fa6
😎 Deploy Preview https://deploy-preview-4113--fastidious-cascaron-4ded94.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment thread docs/api/vi.md Outdated
Comment thread docs/api/vi.md
Comment thread packages/vitest/src/integrations/wait.ts
Comment thread test/core/test/wait.test.ts Outdated
Comment thread test/core/test/wait.test.ts Outdated
Comment thread packages/vitest/src/integrations/wait.ts
Comment thread packages/vitest/src/integrations/wait.ts Outdated
Comment thread packages/vitest/src/integrations/wait.ts Outdated
Comment thread packages/vitest/src/integrations/vi.ts Outdated
Comment thread docs/api/vi.md
Comment thread docs/api/vi.md Outdated
Dunqing and others added 3 commits September 13, 2023 16:01
Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
@sheremet-va

ghost commented Sep 13, 2023

Copy link
Copy Markdown
Member

I would assume waitUntil would be the same function but instead of try/catch it will just check the return value :P

@Dunqing

ghost commented Sep 13, 2023

Copy link
Copy Markdown
Member Author

I would assume waitUntil would be the same function but instead of try/catch it will just check the return value :P

Yes. Do we still need it? Looks like waitFor is enough.

@sheremet-va

ghost commented Sep 13, 2023

Copy link
Copy Markdown
Member

Yes. Do we still need it? Looks like waitFor is enough.

Yes, we still need both. waitUntil should be more performant because throwing an error is expensive, but waitFor can have assertions inside which is a better DX. So, it's about trade-offs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants