Skip to content

Commit

Permalink
fix(allure-playwright): test plan doesn't work for nested files
Browse files Browse the repository at this point in the history
  • Loading branch information
delatrie committed Sep 10, 2024
1 parent bb8ad22 commit 1a628fc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/allure-playwright/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,15 @@ export class AllureReporter implements ReporterV2 {
v1ReporterTests.push(test);
});

// The path needs to be specific to the current OS. Otherwise, it may not match against the test file.
const selectorToGrepPattern = (selector: string) => escapeRegExp(path.normalize(`/${selector}`));

if (v2ReporterTests.length) {
// we need to cut off column because playwright works only with line number
const v2SelectorsArgs = v2ReporterTests
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
.map((test) => test.selector!.replace(/:\d+$/, ""))
.map((selector) => escapeRegExp(selector));
.map(selectorToGrepPattern);

cliArgs.push(...v2SelectorsArgs);
}
Expand All @@ -133,7 +136,7 @@ export class AllureReporter implements ReporterV2 {
// we can filter tests only by absolute path, so we need to cut off test name
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
.map((test) => test.selector!.split("#")[0])
.map((selector) => escapeRegExp(selector));
.map(selectorToGrepPattern);

cliArgs.push(...v1SelectorsArgs);
}
Expand All @@ -142,7 +145,7 @@ export class AllureReporter implements ReporterV2 {
return;
}

configElement.cliArgs = cliArgs.map((selector) => `/${selector}`);
configElement.cliArgs = cliArgs;
}

onError(): void {}
Expand Down

0 comments on commit 1a628fc

Please sign in to comment.