Skip to content

Commit

Permalink
fix(allure-playwright): ignore route.continue() steps
Browse files Browse the repository at this point in the history
  • Loading branch information
baev committed Sep 16, 2024
1 parent 0045cdd commit 248b460
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 @@ -208,6 +208,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 @@ -217,8 +230,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 @@ -229,7 +241,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 248b460

Please sign in to comment.