This commit is contained in:
Yury Semikhatsky 2024-08-27 16:18:14 -07:00
parent e81d982b38
commit fb6a6d0d47

View file

@ -731,12 +731,12 @@ export const test = base.extend({
import { test as base } from '@playwright/test'; import { test as base } from '@playwright/test';
export const test = base.extend({ export const test = base.extend({
sharedAfterEach: [ async ({ page, baseURL }, use) => { sharedAfterEach: [async ({ page, baseURL }, use) => {
await page.goto(baseURL); await page.goto(baseURL);
await use(); await use();
}, { scope: 'test', auto: true } ], // starts automatically before every test, we pass "auto" for that. }, { scope: 'test', auto: true } ], // starts automatically before every test, we pass "auto" for that.
sharedBeforeEach: [ async ({ page }, use) => { sharedBeforeEach: [async ({ page }, use) => {
await use(); await use();
console.log('Test final URL:', page.url()); console.log('Test final URL:', page.url());
}, { scope: 'test', auto: true } ], // starts automatically after every test, we pass "auto" for that. }, { scope: 'test', auto: true } ], // starts automatically after every test, we pass "auto" for that.
@ -763,12 +763,12 @@ that run before/after all tests in every file, you can define them as auto fixtu
import { test as base } from '@playwright/test'; import { test as base } from '@playwright/test';
export const test = base.extend({ export const test = base.extend({
sharedBeforeAll: [ async ({ browser }, use) => { sharedBeforeAll: [async ({ browser }, use) => {
console.log('Before All', browser.version()); console.log('Before All', browser.version());
await use(); await use();
}, { scope: 'worker', auto: true } ], // starts automatically for every worker, we pass "auto" for that. }, { scope: 'worker', auto: true } ], // starts automatically for every worker, we pass "auto" for that.
sharedAfterAll: [ async ({ browser }, use) => { sharedAfterAll: [async ({ browser }, use) => {
console.log('After All', browser.version()); console.log('After All', browser.version());
await use(); await use();
}, { scope: 'worker', auto: true } ], // starts automatically for every worker, we pass "auto" for that. }, { scope: 'worker', auto: true } ], // starts automatically for every worker, we pass "auto" for that.