Skip to content
Open
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
1 change: 1 addition & 0 deletions src/bddData/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class BddDataRenderer {
return {
pwTestLine: this.sourceMapper.getPwTestLine(test.pickle),
pickleLine: test.pickle.location.line,
testTitle: test.testTitle, // store test title for reliable matching in reporter
skipped: test.skipped || undefined,
timeout: test.ownTimeout,
slow: test.slow || undefined,
Expand Down
1 change: 1 addition & 0 deletions src/bddData/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type BddFileData = BddTestData[];
export type BddTestData = {
pwTestLine: number;
pickleLine: number;
testTitle: string; // test title for reliable matching in reporter
tags: string[];
skipped?: boolean;
timeout?: number;
Expand Down
12 changes: 9 additions & 3 deletions src/reporter/cucumber/messagesBuilder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,17 @@ export class MessagesBuilder {
if (!bddConfig) return;

const { bddData, featureUri } = this.testFiles.getBddData(test.location.file);
// todo: move these line somewhere else
const bddTestData = bddData.find((data) => data.pwTestLine === test.location.line);
// Match by test title (reliable) with fallback to line number (legacy).
// Note: Playwright's test.location.line in reporters may point to describe block
// instead of actual test line, so we prefer matching by title.
const bddTestData =
bddData.find((data) => data.testTitle === test.title) ||
bddData.find((data) => data.pwTestLine === test.location.line);
if (!bddTestData) {
const filePath = relativeToCwd(test.location.file);
throw new Error(`Cannot find bddTestData for ${filePath}:${test.location.line}`);
throw new Error(
`Cannot find bddTestData for ${filePath}:${test.location.line} (title: ${test.title})`,
);
}

// Important to create TestCaseRun in this method (not later),
Expand Down