Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(allure-playwright): ignore route.continue() steps #1140

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()",
}),
);
});
Loading