Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(trace): do not nest API actions based on time (#31990)

Yury Semikhatskyfef27395a58a
diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts
index 6dbf290d66..9a159c984a 100644
--- a/packages/playwright/src/index.ts
+++ b/packages/playwright/src/index.ts
@@ -261,7 +261,6 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
title: renderApiCall(apiName, params),
apiName,
params,
- canNestByTime: true,
});
userData.userObject = step;
out.stepId = step.stepId;
diff --git a/packages/playwright/src/worker/testInfo.ts b/packages/playwright/src/worker/testInfo.ts
index bca8e8d96b..fac773f394 100644
--- a/packages/playwright/src/worker/testInfo.ts
+++ b/packages/playwright/src/worker/testInfo.ts
@@ -44,9 +44,6 @@ export interface TestStepInternal {
infectParentStepsWithError?: boolean;
box?: boolean;
isStage?: boolean;
- // TODO: this сould be decided based on the category, but pw:api
- // is from a different abstraction layer.
- canNestByTime?: boolean;
}
export type TestStage = {
@@ -255,11 +252,6 @@ export class TestInfoImpl implements TestInfo {
parentStep = this._findLastStageStep();
} else {
parentStep = zones.zoneData<TestStepInternal>('stepZone');
- if (!parentStep && data.canNestByTime) {
- // API steps (but not test.step calls) can be nested by time, instead of by stack.
- // However, do not nest chains of route.continue by checking the title.
- parentStep = this._findLastNonFinishedStep(step => step.title !== data.title);
- }
if (!parentStep) {
// If no parent step on stack, assume the current stage as parent.
parentStep = this._findLastStageStep();
diff --git a/tests/playwright-test/playwright.trace.spec.ts b/tests/playwright-test/playwright.trace.spec.ts
index 642a3555ca..e4a1efe4d7 100644
--- a/tests/playwright-test/playwright.trace.spec.ts
+++ b/tests/playwright-test/playwright.trace.spec.ts
@@ -1216,9 +1216,9 @@ test('should not nest top level expect into unfinished api calls ', {
' browserContext.newPage',
'page.route',
'page.goto',
- ' route.fetch',
- ' page.unrouteAll',
+ 'route.fetch',
'expect.toBeVisible',
+ 'page.unrouteAll',
'After Hooks',
' fixture: page',
' fixture: context',
diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.ts
index c35070c945..f7538de3e9 100644
--- a/tests/playwright-test/test-step.spec.ts
+++ b/tests/playwright-test/test-step.spec.ts
@@ -542,7 +542,7 @@ fixture | fixture: browser
`);
});
-test('should nest page.continue inside page.goto steps', async ({ runInlineTest }) => {
+test('should not nest page.continue inside page.goto steps', async ({ runInlineTest }) => {
const result = await runInlineTest({
'reporter.ts': stepIndentReporter,
'playwright.config.ts': `module.exports = { reporter: './reporter', };`,
@@ -566,7 +566,7 @@ fixture | fixture: page
pw:api | browserContext.newPage
pw:api |page.route @ a.test.ts:4
pw:api |page.goto(http://localhost:1234) @ a.test.ts:5
-pw:api | route.fulfill @ a.test.ts:4
+pw:api |route.fulfill @ a.test.ts:4
hook |After Hooks
fixture | fixture: page
fixture | fixture: context
@@ -1154,7 +1154,7 @@ pw:api | browserContext.newPage
fixture | fixture: request
pw:api | apiRequest.newContext
pw:api |page.waitForNavigation @ a.test.ts:5
-pw:api | page.goto(data:text/html,<button></button>) @ a.test.ts:6
+pw:api |page.goto(data:text/html,<button></button>) @ a.test.ts:6
pw:api |page.click(button) @ a.test.ts:8
pw:api |locator.getByRole('button').click @ a.test.ts:9
pw:api |apiRequestContext.get(http://localhost2) @ a.test.ts:10