Skip to content

Commit

Permalink
docs: update snippets to fix typescript errors (#32363)
Browse files Browse the repository at this point in the history
Reference: #9468
  • Loading branch information
yury-s authored Aug 28, 2024
1 parent 22fe985 commit d8137f2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions docs/src/test-fixtures-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,8 @@ export const test = base.extend({
```ts title="fixtures.ts"
import { test as base } from '@playwright/test';

export const test = base.extend({
forEachTest: [async ({ page, baseURL }, use) => {
export const test = base.extend<{ forEachTest: void }>({
forEachTest: [async ({ page }, use) => {
// This code runs before every test.
await page.goto('http://localhost:8000');
await use();
Expand All @@ -747,8 +747,9 @@ And then import the fixtures in all your tests:
import { test } from './fixtures';
import { expect } from '@playwright/test';

test('basic', async ({ page, baseURL }) => {
expect(page).toHaveURL(baseURL!);
test('basic', async ({ page }) => {
expect(page).toHaveURL('http://localhost:8000');
await page.goto('https://playwright.dev');
});
```

Expand All @@ -760,7 +761,7 @@ that run before/after all tests in every file, you can declare them as auto fixt
```ts title="fixtures.ts"
import { test as base } from '@playwright/test';

export const test = base.extend({
export const test = base.extend<{}, { forEachWorker: void }>({
forEachWorker: [async ({}, use) => {
// This code runs before all the tests in the worker process.
console.log(`Starting test worker ${test.info().workerIndex}`);
Expand Down

0 comments on commit d8137f2

Please sign in to comment.