Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: throw an error and a warning if .poll, .element, .rejects/.resolves, and locator.* weren't awaited #6877

Merged
merged 16 commits into from
Nov 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: add docs about warnings and errors if async is not awaited
sheremet-va committed Nov 12, 2024

Unverified

No user is associated with the committer email.
commit bb508f4e8ba02375c0e5bff09aac0b8376d9f71f
4 changes: 4 additions & 0 deletions docs/api/expect.md
Original file line number Diff line number Diff line change
@@ -1185,6 +1185,8 @@ test('buyApples returns new stock id', async () => {

:::warning
If the assertion is not awaited, then you will have a false-positive test that will pass every time. To make sure that assertions are actually called, you may use [`expect.assertions(number)`](#expect-assertions).

Since Vitest 2.2, if a method is not awaited, Vitest will show a warning at the end of the test. In Vitest 3, the test will be marked as "failed" if the assertion is not awaited.
:::

## rejects
@@ -1214,6 +1216,8 @@ test('buyApples throws an error when no id provided', async () => {

:::warning
If the assertion is not awaited, then you will have a false-positive test that will pass every time. To make sure that assertions were actually called, you can use [`expect.assertions(number)`](#expect-assertions).

Since Vitest 2.2, if a method is not awaited, Vitest will show a warning at the end of the test. In Vitest 3, the test will be marked as "failed" if the assertion is not awaited.
:::

## expect.assertions
2 changes: 2 additions & 0 deletions docs/guide/browser/locators.md
Original file line number Diff line number Diff line change
@@ -389,6 +389,8 @@ It is recommended to use this only after the other locators don't work for your

## Methods

All methods are asynchronous and must be awaited. Since Vitest 2.2, tests will fail if a method is not awaited.

### click

```ts