mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs: update snippets to fix typescript errors (#32363)
Reference: https://github.com/microsoft/playwright/issues/9468
This commit is contained in:
parent
22fe985c54
commit
d8137f228f
@ -730,8 +730,8 @@ export const test = base.extend({
|
|||||||
```ts title="fixtures.ts"
|
```ts title="fixtures.ts"
|
||||||
import { test as base } from '@playwright/test';
|
import { test as base } from '@playwright/test';
|
||||||
|
|
||||||
export const test = base.extend({
|
export const test = base.extend<{ forEachTest: void }>({
|
||||||
forEachTest: [async ({ page, baseURL }, use) => {
|
forEachTest: [async ({ page }, use) => {
|
||||||
// This code runs before every test.
|
// This code runs before every test.
|
||||||
await page.goto('http://localhost:8000');
|
await page.goto('http://localhost:8000');
|
||||||
await use();
|
await use();
|
||||||
@ -747,8 +747,9 @@ And then import the fixtures in all your tests:
|
|||||||
import { test } from './fixtures';
|
import { test } from './fixtures';
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
test('basic', async ({ page, baseURL }) => {
|
test('basic', async ({ page }) => {
|
||||||
expect(page).toHaveURL(baseURL!);
|
expect(page).toHaveURL('http://localhost:8000');
|
||||||
|
await page.goto('https://playwright.dev');
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -760,7 +761,7 @@ that run before/after all tests in every file, you can declare them as auto fixt
|
|||||||
```ts title="fixtures.ts"
|
```ts title="fixtures.ts"
|
||||||
import { test as base } from '@playwright/test';
|
import { test as base } from '@playwright/test';
|
||||||
|
|
||||||
export const test = base.extend({
|
export const test = base.extend<{}, { forEachWorker: void }>({
|
||||||
forEachWorker: [async ({}, use) => {
|
forEachWorker: [async ({}, use) => {
|
||||||
// This code runs before all the tests in the worker process.
|
// This code runs before all the tests in the worker process.
|
||||||
console.log(`Starting test worker ${test.info().workerIndex}`);
|
console.log(`Starting test worker ${test.info().workerIndex}`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user