mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
Update best-practices-js.md (#23466)
This commit is contained in:
parent
5a14619bab
commit
49c8c6fa33
@ -136,7 +136,7 @@ Assertions are a way to verify that the expected result and the actual result ma
|
|||||||
|
|
||||||
#### Don't use manual assertions
|
#### Don't use manual assertions
|
||||||
|
|
||||||
Don't use manual assertions that are not awaiting the expect. In the code below the await is inside the expect rather than before it. When using assertions such as `isVisible()` the test wont wait a single second, it will just check the locator is there and return immediately.
|
Don't use manual assertions that are not awaiting the expect. In the code below the await is inside the expect rather than before it. When using assertions such as `isVisible()` the test won't wait a single second, it will just check the locator is there and return immediately.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
👎 expect(await page.getByText('welcome').isVisible()).toBe(true);
|
👎 expect(await page.getByText('welcome').isVisible()).toBe(true);
|
||||||
@ -285,4 +285,4 @@ await expect.soft(page.getByTestId('status')).toHaveText('Success');
|
|||||||
|
|
||||||
// ... and continue the test to check more things.
|
// ... and continue the test to check more things.
|
||||||
await page.getByRole('link', { name: 'next page' }).click();
|
await page.getByRole('link', { name: 'next page' }).click();
|
||||||
```
|
```
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user