Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: cleanup api calls in builtin fixtures (#36937)
Dmitry Gozman6971d75024b9
diff --git a/packages/playwright-core/src/client/browser.ts b/packages/playwright-core/src/client/browser.tsindex 34ba2b0a7c..80d2ff2fb9 100644--- a/packages/playwright-core/src/client/browser.ts+++ b/packages/playwright-core/src/client/browser.ts@@ -60,20 +60,18 @@ export class Browser extends ChannelOwner<channels.BrowserChannel> implements ap}async _newContextForReuse(options: BrowserContextOptions = {}): Promise<BrowserContext> {- return await this._wrapApiCall(() => this._innerNewContext(options, true), { internal: true });+ return await this._innerNewContext(options, true);}async _disconnectFromReusedContext(reason: string) {- return await this._wrapApiCall(async () => {- const context = [...this._contexts].find(context => context._forReuse);- if (!context)- return;- await this._instrumentation.runBeforeCloseBrowserContext(context);- for (const page of context.pages())- page._onClose();- context._onClose();- await this._channel.disconnectFromReusedContext({ reason });- }, { internal: true });+ const context = [...this._contexts].find(context => context._forReuse);+ if (!context)+ return;+ await this._instrumentation.runBeforeCloseBrowserContext(context);+ for (const page of context.pages())+ page._onClose();+ context._onClose();+ await this._channel.disconnectFromReusedContext({ reason });}async _innerNewContext(options: BrowserContextOptions = {}, forReuse: boolean): Promise<BrowserContext> {diff --git a/packages/playwright-core/src/client/browserContext.ts b/packages/playwright-core/src/client/browserContext.tsindex 5a1bad8987..fa309a7b5c 100644--- a/packages/playwright-core/src/client/browserContext.ts+++ b/packages/playwright-core/src/client/browserContext.ts@@ -495,8 +495,8 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>this._closeReason = options.reason;this._closingStatus = 'closing';await this.request.dispose(options);+ await this._instrumentation.runBeforeCloseBrowserContext(this);await this._wrapApiCall(async () => {- await this._instrumentation.runBeforeCloseBrowserContext(this);for (const [harId, harParams] of this._harRecorders) {const har = await this._channel.harExport({ harId });const artifact = Artifact.from(har.artifact);diff --git a/packages/playwright-core/src/client/browserType.ts b/packages/playwright-core/src/client/browserType.tsindex e41b0db69a..af99f15dc7 100644--- a/packages/playwright-core/src/client/browserType.ts+++ b/packages/playwright-core/src/client/browserType.ts@@ -108,15 +108,16 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel> impleuserDataDir: (this._platform.path().isAbsolute(userDataDir) || !userDataDir) ? userDataDir : this._platform.path().resolve(userDataDir),timeout: new TimeoutSettings(this._platform).launchTimeout(options),};- return await this._wrapApiCall(async () => {+ const context = await this._wrapApiCall(async () => {const result = await this._channel.launchPersistentContext(persistentParams);const browser = Browser.from(result.browser);browser._connectToBrowserType(this, options, logger);const context = BrowserContext.from(result.context);await context._initializeHarFromOptions(options.recordHar);- await this._instrumentation.runAfterCreateBrowserContext(context);return context;});+ await this._instrumentation.runAfterCreateBrowserContext(context);+ return context;}connect(options: api.ConnectOptions & { wsEndpoint: string }): Promise<Browser>;diff --git a/packages/playwright-ct-core/src/mount.ts b/packages/playwright-ct-core/src/mount.tsindex 94c7de8d3d..2dc1d88287 100644--- a/packages/playwright-ct-core/src/mount.ts+++ b/packages/playwright-ct-core/src/mount.ts@@ -21,7 +21,7 @@ import type { ContextReuseMode, FullConfigInternal } from '../../playwright/src/import type { RouterFixture } from '../index';import type { ImportRef } from './injected/importRegistry';import type { Component, JsxComponent, MountOptions, ObjectComponentOptions } from '../types/component';-import type { BrowserContext, BrowserContextOptions, Fixtures, Locator, Page, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions } from 'playwright/test';+import type { Fixtures, Locator, Page, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions } from 'playwright/test';import type { Page as PageImpl } from 'playwright-core/lib/client/page';let boundCallbacksForMount: Function[] = [];@@ -37,7 +37,6 @@ type TestFixtures = PlaywrightTestArgs & PlaywrightTestOptions & {};type WorkerFixtures = PlaywrightWorkerArgs & PlaywrightWorkerOptions;type BaseTestFixtures = {- _contextFactory: (options?: BrowserContextOptions) => Promise<BrowserContext>,_optionContextReuseMode: ContextReuseMode};diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.tsindex 146e6acb66..5a2948b157 100644--- a/packages/playwright/src/index.ts+++ b/packages/playwright/src/index.ts@@ -31,8 +31,10 @@ import type { ClientInstrumentationListener } from '../../playwright-core/src/climport type { Playwright as PlaywrightImpl } from '../../playwright-core/src/client/playwright';import type { Browser as BrowserImpl } from '../../playwright-core/src/client/browser';import type { BrowserContext as BrowserContextImpl } from '../../playwright-core/src/client/browserContext';+import type { APIRequestContext as APIRequestContextImpl } from '../../playwright-core/src/client/fetch';+import type { ChannelOwner } from '../../playwright-core/src/client/channelOwner';import type { Page as PageImpl } from '../../playwright-core/src/client/page';-import type { APIRequestContext, Browser, BrowserContext, BrowserContextOptions, LaunchOptions, Page, Tracing, Video } from 'playwright-core';+import type { BrowserContext, BrowserContextOptions, LaunchOptions, Page, Tracing } from 'playwright-core';export { expect } from './matchers/expect';export const _baseTest: TestType<{}, {}> = rootTestType.test;@@ -55,7 +57,7 @@ type TestFixtures = PlaywrightTestArgs & PlaywrightTestOptions & {_combinedContextOptions: BrowserContextOptions,_setupContextOptions: void;_setupArtifacts: void;- _contextFactory: (options?: BrowserContextOptions) => Promise<BrowserContext>;+ _contextFactory: (options?: BrowserContextOptions) => Promise<{ context: BrowserContext, close: () => Promise<void> }>;};type WorkerFixtures = PlaywrightWorkerArgs & PlaywrightWorkerOptions & {@@ -113,17 +115,13 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({},});await use(browser);- await (browser as BrowserImpl)._wrapApiCall(async () => {- await browser.close({ reason: 'Test ended.' });- }, { internal: true });+ await browser.close({ reason: 'Test ended.' });return;}const browser = await playwright[browserName].launch();await use(browser);- await (browser as BrowserImpl)._wrapApiCall(async () => {- await browser.close({ reason: 'Test ended.' });- }, { internal: true });+ await browser.close({ reason: 'Test ended.' });}, { scope: 'worker', timeout: 0 }],acceptDownloads: [({ contextOptions }, use) => use(contextOptions.acceptDownloads ?? true), { option: true }],@@ -304,24 +302,24 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({if (!keepTestTimeout)currentTestInfo()?._setDebugMode();},- runAfterCreateBrowserContext: async (context: BrowserContext) => {+ runAfterCreateBrowserContext: async (context: BrowserContextImpl) => {await artifactsRecorder?.didCreateBrowserContext(context);const testInfo = currentTestInfo();if (testInfo)attachConnectedHeaderIfNeeded(testInfo, context.browser());},- runAfterCreateRequestContext: async (context: APIRequestContext) => {+ runAfterCreateRequestContext: async (context: APIRequestContextImpl) => {await artifactsRecorder?.didCreateRequestContext(context);},- runBeforeCloseBrowserContext: async (context: BrowserContext) => {+ runBeforeCloseBrowserContext: async (context: BrowserContextImpl) => {await artifactsRecorder?.willCloseBrowserContext(context);},- runBeforeCloseRequestContext: async (context: APIRequestContext) => {+ runBeforeCloseRequestContext: async (context: APIRequestContextImpl) => {await artifactsRecorder?.willCloseRequestContext(context);},};- const clientInstrumentation = (playwright as PlaywrightImpl)._instrumentation;+ const clientInstrumentation = playwright._instrumentation;clientInstrumentation.addListener(csiListener);await use();@@ -334,7 +332,8 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({const testInfoImpl = testInfo as TestInfoImpl;const videoMode = normalizeVideoMode(video);const captureVideo = shouldCaptureVideo(videoMode, testInfo) && !_reuseContext;- const contexts = new Map<BrowserContext, { pagesWithVideo: Page[] }>();+ const contexts = new Map<BrowserContext, { close: () => Promise<void>, pagesWithVideo: Page[] }>();+ let counter = 0;await use(async options => {const hook = testInfoImpl._currentHookType();@@ -351,50 +350,52 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({size: typeof video === 'string' ? undefined : video.size,}} : {};- const context = await browser.newContext({ ...videoOptions, ...options });- const contextData: { pagesWithVideo: Page[] } = { pagesWithVideo: [] };- contexts.set(context, contextData);- if (captureVideo)- context.on('page', page => contextData.pagesWithVideo.push(page));+ const context = await browser.newContext({ ...videoOptions, ...options }) as BrowserContextImpl;if (process.env.PW_CLOCK === 'frozen') {- await (context as BrowserContextImpl)._wrapApiCall(async () => {+ await context._wrapApiCall(async () => {await context.clock.install({ time: 0 });await context.clock.pauseAt(1000);}, { internal: true });} else if (process.env.PW_CLOCK === 'realtime') {- await (context as BrowserContextImpl)._wrapApiCall(async () => {+ await context._wrapApiCall(async () => {await context.clock.install({ time: 0 });}, { internal: true });}- return context;- });-- let counter = 0;- const closeReason = testInfo.status === 'timedOut' ? 'Test timeout of ' + testInfo.timeout + 'ms exceeded.' : 'Test ended.';- await Promise.all([...contexts.keys()].map(async context => {- await (context as BrowserContextImpl)._wrapApiCall(async () => {+ let closed = false;+ const close = async () => {+ if (closed)+ return;+ closed = true;+ const closeReason = testInfo.status === 'timedOut' ? 'Test timeout of ' + testInfo.timeout + 'ms exceeded.' : 'Test ended.';await context.close({ reason: closeReason });- }, { internal: true });- const testFailed = testInfo.status !== testInfo.expectedStatus;- const preserveVideo = captureVideo && (videoMode === 'on' || (testFailed && videoMode === 'retain-on-failure') || (videoMode === 'on-first-retry' && testInfo.retry === 1));- if (preserveVideo) {- const { pagesWithVideo: pagesForVideo } = contexts.get(context)!;- const videos = pagesForVideo.map(p => p.video()).filter(Boolean) as Video[];- await Promise.all(videos.map(async v => {- try {- const savedPath = testInfo.outputPath(`video${counter ? '-' + counter : ''}.webm`);- ++counter;- await v.saveAs(savedPath);- testInfo.attachments.push({ name: 'video', path: savedPath, contentType: 'video/webm' });- } catch (e) {- // Silent catch empty videos.- }- }));- }- }));+ const testFailed = testInfo.status !== testInfo.expectedStatus;+ const preserveVideo = captureVideo && (videoMode === 'on' || (testFailed && videoMode === 'retain-on-failure') || (videoMode === 'on-first-retry' && testInfo.retry === 1));+ if (preserveVideo) {+ const { pagesWithVideo: pagesForVideo } = contexts.get(context)!;+ const videos = pagesForVideo.map(p => p.video()).filter(video => !!video);+ await Promise.all(videos.map(async v => {+ try {+ const savedPath = testInfo.outputPath(`video${counter ? '-' + counter : ''}.webm`);+ ++counter;+ await v.saveAs(savedPath);+ testInfo.attachments.push({ name: 'video', path: savedPath, contentType: 'video/webm' });+ } catch (e) {+ // Silent catch empty videos.+ }+ }));+ }+ };+ const contextData = { close, pagesWithVideo: [] as Page[] };+ if (captureVideo)+ context.on('page', page => contextData.pagesWithVideo.push(page));+ contexts.set(context, contextData);+ return { context, close };+ });++ await Promise.all([...contexts.values()].map(data => data.close()));}, { scope: 'test', title: 'context', box: true }],_optionContextReuseMode: ['none', { scope: 'worker', option: true }],@@ -408,18 +409,20 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({await use(reuse);}, { scope: 'worker', title: 'context', box: true }],- context: async ({ playwright, browser, _reuseContext, _contextFactory }, use, testInfo) => {- attachConnectedHeaderIfNeeded(testInfo, browser);+ context: async ({ browser, _reuseContext, _contextFactory }, use, testInfo) => {+ const browserImpl = browser as BrowserImpl;+ attachConnectedHeaderIfNeeded(testInfo, browserImpl);if (!_reuseContext) {- await use(await _contextFactory());+ const { context, close } = await _contextFactory();+ await use(context);+ await close();return;}- const defaultContextOptions = (playwright.chromium as any)._defaultContextOptions as BrowserContextOptions;- const context = await (browser as BrowserImpl)._newContextForReuse(defaultContextOptions);+ const context = await browserImpl._wrapApiCall(() => browserImpl._newContextForReuse(), { internal: true });await use(context);const closeReason = testInfo.status === 'timedOut' ? 'Test timeout of ' + testInfo.timeout + 'ms exceeded.' : 'Test ended.';- await (browser as BrowserImpl)._disconnectFromReusedContext(closeReason);+ await browserImpl._wrapApiCall(() => browserImpl._disconnectFromReusedContext(closeReason), { internal: true });},page: async ({ context, _reuseContext }, use) => {@@ -473,8 +476,8 @@ function normalizeScreenshotMode(screenshot: ScreenshotOption): ScreenshotMode {return typeof screenshot === 'string' ? screenshot : screenshot.mode;}-function attachConnectedHeaderIfNeeded(testInfo: TestInfo, browser: Browser | null) {- const connectHeaders: { name: string, value: string }[] | undefined = (browser as BrowserImpl | null)?._connection.headers;+function attachConnectedHeaderIfNeeded(testInfo: TestInfo, browser: BrowserImpl | null) {+ const connectHeaders: { name: string, value: string }[] | undefined = browser?._connection.headers;if (!connectHeaders)return;for (const header of connectHeaders) {@@ -535,7 +538,7 @@ class SnapshotRecorder {private _name: string,private _contentType: string,private _extension: string,- private _doSnapshot: (page: Page, path: string) => Promise<void>) {+ private _doSnapshot: (page: PageImpl, path: string) => Promise<void>) {}fixOrdinal() {@@ -570,7 +573,7 @@ class SnapshotRecorder {}}- async captureTemporary(context: BrowserContext) {+ async captureTemporary(context: BrowserContextImpl) {if (this._mode === 'on' || this._mode === 'only-on-failure' || (this._mode === 'on-first-failure' && this.testInfo.retry === 0))await Promise.all(context.pages().map(page => this._snapshotPage(page, true)));}@@ -592,7 +595,7 @@ class SnapshotRecorder {return file;}- private async _snapshotPage(page: Page, temporary: boolean) {+ private async _snapshotPage(page: PageImpl, temporary: boolean) {// Make sure we do not snapshot the same page twice for a single TestInfo,// which is reused between beforeAll(s), test and afterAll(s).if ((page as any)[this.testInfo._uniqueSymbol])@@ -631,7 +634,9 @@ class ArtifactsRecorder {this._startedCollectingArtifacts = Symbol('startedCollectingArtifacts');this._screenshotRecorder = new SnapshotRecorder(this, normalizeScreenshotMode(screenshot), 'screenshot', 'image/png', '.png', async (page, path) => {- await page.screenshot({ ...screenshotOptions, timeout: 5000, path, caret: 'initial' });+ await page._wrapApiCall(async () => {+ await page.screenshot({ ...screenshotOptions, timeout: 5000, path, caret: 'initial' });+ }, { internal: true });});}@@ -643,21 +648,21 @@ class ArtifactsRecorder {// Process existing contexts.await Promise.all(this._playwright._allContexts().map(context => this.didCreateBrowserContext(context)));- const existingApiRequests = Array.from((this._playwright.request as any)._contexts as Set<APIRequestContext>);+ const existingApiRequests = Array.from(this._playwright.request._contexts);await Promise.all(existingApiRequests.map(c => this.didCreateRequestContext(c)));}- async didCreateBrowserContext(context: BrowserContext) {- await this._startTraceChunkOnContextCreation(context.tracing);+ async didCreateBrowserContext(context: BrowserContextImpl) {+ await this._startTraceChunkOnContextCreation(context, context.tracing);}- async willCloseBrowserContext(context: BrowserContext) {- await this._stopTracing(context.tracing);+ async willCloseBrowserContext(context: BrowserContextImpl) {+ await this._stopTracing(context, context.tracing);await this._screenshotRecorder.captureTemporary(context);await this._takePageSnapshot(context);}- private async _takePageSnapshot(context: BrowserContext) {+ private async _takePageSnapshot(context: BrowserContextImpl) {if (process.env.PLAYWRIGHT_NO_COPY_PROMPT)return;if (this._testInfo.errors.length === 0)@@ -670,18 +675,18 @@ class ArtifactsRecorder {try {// TODO: maybe capture snapshot when the error is created, so it's from the right page and right time- this._pageSnapshot = await (page as PageImpl)._snapshotForAI({ timeout: 5000 });+ await page._wrapApiCall(async () => {+ this._pageSnapshot = await page._snapshotForAI({ timeout: 5000 });+ }, { internal: true });} catch {}}- async didCreateRequestContext(context: APIRequestContext) {- const tracing = (context as any)._tracing as Tracing;- await this._startTraceChunkOnContextCreation(tracing);+ async didCreateRequestContext(context: APIRequestContextImpl) {+ await this._startTraceChunkOnContextCreation(context, context._tracing);}- async willCloseRequestContext(context: APIRequestContext) {- const tracing = (context as any)._tracing as Tracing;- await this._stopTracing(tracing);+ async willCloseRequestContext(context: APIRequestContextImpl) {+ await this._stopTracing(context, context._tracing);}async didFinishTestFunction() {@@ -692,14 +697,13 @@ class ArtifactsRecorder {await this.didFinishTestFunction();const leftoverContexts = this._playwright._allContexts();- const leftoverApiRequests = Array.from((this._playwright.request as any)._contexts as Set<APIRequestContext>);+ const leftoverApiRequests = Array.from(this._playwright.request._contexts);// Collect traces/screenshots for remaining contexts.await Promise.all(leftoverContexts.map(async context => {- await this._stopTracing(context.tracing);+ await this._stopTracing(context, context.tracing);}).concat(leftoverApiRequests.map(async context => {- const tracing = (context as any)._tracing as Tracing;- await this._stopTracing(tracing);+ await this._stopTracing(context, context._tracing);})));await this._screenshotRecorder.persistTemporary();@@ -727,31 +731,35 @@ class ArtifactsRecorder {}}- private async _startTraceChunkOnContextCreation(tracing: Tracing) {- const options = this._testInfo._tracing.traceOptions();- if (options) {- const title = this._testInfo._tracing.traceTitle();- const name = this._testInfo._tracing.generateNextTraceRecordingName();- if (!(tracing as any)[kTracingStarted]) {- await tracing.start({ ...options, title, name });- (tracing as any)[kTracingStarted] = true;+ private async _startTraceChunkOnContextCreation(channelOwner: ChannelOwner, tracing: Tracing) {+ await channelOwner._wrapApiCall(async () => {+ const options = this._testInfo._tracing.traceOptions();+ if (options) {+ const title = this._testInfo._tracing.traceTitle();+ const name = this._testInfo._tracing.generateNextTraceRecordingName();+ if (!(tracing as any)[kTracingStarted]) {+ await tracing.start({ ...options, title, name });+ (tracing as any)[kTracingStarted] = true;+ } else {+ await tracing.startChunk({ title, name });+ }} else {- await tracing.startChunk({ title, name });- }- } else {- if ((tracing as any)[kTracingStarted]) {- (tracing as any)[kTracingStarted] = false;- await tracing.stop();+ if ((tracing as any)[kTracingStarted]) {+ (tracing as any)[kTracingStarted] = false;+ await tracing.stop();+ }}- }+ }, { internal: true });}- private async _stopTracing(tracing: Tracing) {- if ((tracing as any)[this._startedCollectingArtifacts])- return;- (tracing as any)[this._startedCollectingArtifacts] = true;- if (this._testInfo._tracing.traceOptions() && (tracing as any)[kTracingStarted])- await tracing.stopChunk({ path: this._testInfo._tracing.maybeGenerateNextTraceRecordingPath() });+ private async _stopTracing(channelOwner: ChannelOwner, tracing: Tracing) {+ await channelOwner._wrapApiCall(async () => {+ if ((tracing as any)[this._startedCollectingArtifacts])+ return;+ (tracing as any)[this._startedCollectingArtifacts] = true;+ if (this._testInfo._tracing.traceOptions() && (tracing as any)[kTracingStarted])+ await tracing.stopChunk({ path: this._testInfo._tracing.maybeGenerateNextTraceRecordingPath() });+ }, { internal: true });}}diff --git a/tests/config/browserTest.ts b/tests/config/browserTest.tsindex 82111b24a1..45cf6fba67 100644--- a/tests/config/browserTest.ts+++ b/tests/config/browserTest.ts@@ -105,7 +105,10 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>}, { scope: 'worker' }],contextFactory: async ({ _contextFactory }: any, run) => {- await run(_contextFactory);+ await run(async options => {+ const { context } = await _contextFactory(options);+ return context;+ });},createUserDataDir: async ({ mode }, run) => {diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.tsindex f4e4fcf18e..80502d8ea6 100644--- a/tests/library/trace-viewer.spec.ts+++ b/tests/library/trace-viewer.spec.ts@@ -170,6 +170,8 @@ test('should open simple trace viewer', async ({ showTraceViewer }) => {/Wait for timeout/,/Navigate to "\/frames\/frame.html"/,/Set viewport size/,+ /Hover/,+ /Close page/,]);});@@ -1599,7 +1601,8 @@ test('should not leak recorders', {return frame;};- await expect(traceViewer.snapshotContainer.contentFrame().locator('body')).toContainText(`Hi, I'm frame`);+ const frame0 = await traceViewer.snapshotFrame('Set viewport');+ await expect(frame0.locator('body')).toContainText(`Hi, I'm frame`);const frame1 = await forceRecorder('Navigate');await expect(frame1.locator('body')).toContainText('Hello world');@@ -1847,6 +1850,8 @@ test('should render blob trace received from message', async ({ showTraceViewer/Wait for timeout/,/Navigate to "\/frames\/frame.html"/,/Set viewport size/,+ /Hover/,+ /Close page/,]);});diff --git a/tests/playwright-test/playwright.connect.spec.ts b/tests/playwright-test/playwright.connect.spec.tsindex 7039b2a128..0584bd88c4 100644--- a/tests/playwright-test/playwright.connect.spec.ts+++ b/tests/playwright-test/playwright.connect.spec.ts@@ -223,6 +223,7 @@ test('should record trace', async ({ runInlineTest }) => {'After Hooks','Fixture "page"','Fixture "context"',+ 'Close context','Worker Cleanup','Fixture "browser"',]);diff --git a/tests/playwright-test/playwright.trace.spec.ts b/tests/playwright-test/playwright.trace.spec.tsindex 745a1dee31..6ea56bb378 100644--- a/tests/playwright-test/playwright.trace.spec.ts+++ b/tests/playwright-test/playwright.trace.spec.ts@@ -102,6 +102,7 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {'After Hooks',' Fixture "page"',' Fixture "context"',+ ' Close context',' Fixture "request"',]);const trace2 = await parseTrace(testInfo.outputPath('test-results', 'a-api-pass', 'trace.zip'));@@ -126,6 +127,7 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {'After Hooks',' Fixture "page"',' Fixture "context"',+ ' Close context',' Fixture "request"','Worker Cleanup',' Fixture "browser"',@@ -325,6 +327,7 @@ test('should not override trace file in afterAll', async ({ runInlineTest, serve'After Hooks',' Fixture "page"',' Fixture "context"',+ ' Close context',' afterAll hook',' Fixture "request"',' Create request context',@@ -615,6 +618,7 @@ test('should expand expect.toPass', async ({ runInlineTest }, testInfo) => {'After Hooks',' Fixture "page"',' Fixture "context"',+ ' Close context',]);});@@ -648,6 +652,7 @@ test('should show non-expect error in trace', async ({ runInlineTest }, testInfo'After Hooks',' Fixture "page"',' Fixture "context"',+ ' Close context','Worker Cleanup',' Fixture "browser"',]);@@ -776,6 +781,7 @@ test('should use custom expect message in trace', async ({ runInlineTest }, test'After Hooks',' Fixture "page"',' Fixture "context"',+ ' Close context',]);});@@ -959,6 +965,7 @@ test('should record nested steps, even after timeout', async ({ runInlineTest },' Set content',' Fixture "page"',' Fixture "context"',+ ' Close context',' afterAll hook',' Fixture "barPage"',' Expect "barPage setup"',@@ -1018,6 +1025,7 @@ test('should not produce an action entry for calling a binding', async ({ runInl'After Hooks',' Fixture "page"',' Fixture "context"',+ ' Close context',]);});@@ -1248,6 +1256,7 @@ test('should not nest top level expect into unfinished api calls ', {'After Hooks',' Fixture "page"',' Fixture "context"',+ ' Close context',]);});diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.tsindex dd56fa860c..104aa221db 100644--- a/tests/playwright-test/test-step.spec.ts+++ b/tests/playwright-test/test-step.spec.ts@@ -153,6 +153,7 @@ test.step | inner step 2.2 @ a.test.ts:10hook |After Hooksfixture | pagefixture | context+pw:api | Close context`);});@@ -217,6 +218,7 @@ test.step |my step @ a.test.ts:4hook |After Hooksfixture | pagefixture | context+pw:api | Close contexthook |Worker Cleanupfixture | browser|Test timeout of 2000ms exceeded.@@ -566,6 +568,7 @@ hook | afterEach hook @ a.test.ts:15test.step | in afterEach @ a.test.ts:16fixture | pagefixture | context+pw:api | Close contexthook | afterAll hook @ a.test.ts:7test.step | in afterAll @ a.test.ts:8`);@@ -893,6 +896,7 @@ expect |Checking color @ a.test.ts:6hook |After Hooksfixture | pagefixture | context+pw:api | Close context`);});@@ -989,6 +993,7 @@ expect | toBe @ a.test.ts:9hook |After Hooksfixture | pagefixture | context+pw:api | Close context`);});@@ -1041,6 +1046,7 @@ expect | toHaveLength @ a.test.ts:6hook |After Hooksfixture | pagefixture | context+pw:api | Close context`);});@@ -1093,6 +1099,7 @@ expect | toBe @ a.test.ts:6hook |After Hooksfixture | pagefixture | context+pw:api | Close context`);});@@ -1142,6 +1149,7 @@ expect |not toHaveTitle @ a.test.ts:11hook |After Hooksfixture | pagefixture | context+pw:api | Close context`);});@@ -1230,6 +1238,7 @@ hook |After Hooksfixture | requestfixture | pagefixture | context+pw:api | Close context`);});@@ -1265,6 +1274,7 @@ pw:api |↪ error: TimeoutError: page.click: Timeout 1ms exceeded.hook |After Hooksfixture | pagefixture | context+pw:api | Close contexthook |Worker Cleanupfixture | browser|TimeoutError: page.click: Timeout 1ms exceeded.@@ -1301,6 +1311,7 @@ pw:api |Evaluate locator('button') @ a.test.ts:6hook |After Hooksfixture | pagefixture | context+pw:api | Close context`);});@@ -1390,6 +1401,7 @@ pw:api | Set content @ a.test.ts:8hook |After Hooksfixture | pagefixture | context+pw:api | Close context`);});@@ -1444,6 +1456,7 @@ expect |toBe @ a.test.ts:18hook |After Hooksfixture | pagefixture | context+pw:api | Close context`);});@@ -1480,6 +1493,7 @@ pw:api |Navigate to "/empty.html" @ a.test.ts:10hook |After Hooksfixture | pagefixture | context+pw:api | Close context`);});@@ -1524,6 +1538,7 @@ expect | toBe @ a.test.ts:8hook |After Hooksfixture | pagefixture | context+pw:api | Close context`);});@@ -1749,5 +1764,6 @@ pw:api |Set content @ a.test.ts:19hook |After Hooksfixture | pagefixture | context+pw:api | Close context`);});diff --git a/tests/playwright-test/to-have-screenshot.spec.ts b/tests/playwright-test/to-have-screenshot.spec.tsindex df46e9c2bc..b7d6ed5c91 100644--- a/tests/playwright-test/to-have-screenshot.spec.ts+++ b/tests/playwright-test/to-have-screenshot.spec.ts@@ -268,6 +268,7 @@ test('should report toHaveScreenshot step with expectation name in title', async`end [expect] toHaveScreenshot(foo.png)`,`end [expect] toHaveScreenshot(is-a-test-1.png)`,`end [fixture] page`,+ `end [pw:api] Close context`,`end [fixture] context`,`end [hook] After Hooks`,]);