Skip to content

Commit

Permalink
fix(allure-playwright): ignore route.continue() steps (fixes #1139, f…
Browse files Browse the repository at this point in the history
…ixes #414, via #1140)
  • Loading branch information
baev authored Sep 16, 2024
1 parent cf6451b commit 570ed4b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/allure-playwright/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,19 @@ export class AllureReporter implements ReporterV2 {
this.startedTestCasesTitlesCache.push(titleMetadata.cleanTitle);
}

#shouldIgnoreStep(step: TestStep) {
if (!this.options.detail && step.category !== "test.step") {
return true;
}

// ignore noisy route.continue()
if (step.category === "pw:api" && step.title === "route.continue()") {
return true;
}

return false;
}

onStepBegin(test: TestCase, _result: PlaywrightTestResult, step: TestStep): void {
const testUuid = this.allureResultsUuids.get(test.id)!;

Expand All @@ -220,8 +233,7 @@ export class AllureReporter implements ReporterV2 {
return;
}

// TODO fix the details disable, e.g. only ignore pw:api steps
if (!this.options.detail && step.category !== "test.step") {
if (this.#shouldIgnoreStep(step)) {
return;
}

Expand All @@ -232,7 +244,7 @@ export class AllureReporter implements ReporterV2 {
}

onStepEnd(test: TestCase, _result: PlaywrightTestResult, step: TestStep): void {
if (!this.options.detail && step.category !== "test.step") {
if (this.#shouldIgnoreStep(step)) {
return;
}

Expand Down
23 changes: 23 additions & 0 deletions packages/allure-playwright/test/spec/steps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,26 @@ it("should support steps with names longer then 50 chars", async () => {
}),
]);
});

it("should ignore route.continue() steps", async () => {
const { tests } = await runPlaywrightInlineTest({
"a.test.js": `
import { test, expect } from '@playwright/test';
test('a test', async ({ page }) => {
await page.route('**/*', (route) => {
route.continue();
});
await page.goto("https://allurereport.org");
});
`,
});

expect(tests).toHaveLength(1);
const [tr] = tests;
expect(tr.steps).not.toContainEqual(
expect.objectContaining({
name: "route.continue()",
}),
);
});

0 comments on commit 570ed4b

Please sign in to comment.