Skip to content

Commit 575a9cd

Browse files
committed
add cucumber query
1 parent bfa96d2 commit 575a9cd

File tree

7 files changed

+32
-25
lines changed

7 files changed

+32
-25
lines changed

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"@cucumber/html-formatter": "^21.11.0",
6868
"@cucumber/junit-xml-formatter": "^0.13.2",
6969
"@cucumber/messages": "^27.2.0",
70+
"@cucumber/query": "^15.0.1",
7071
"@cucumber/tag-expressions": "^6.2.0",
7172
"cli-table3": "0.6.5",
7273
"commander": "^13.1.0",

src/cucumber/valueChecker.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@ export function doesHaveValue<T>(value: T): value is NonNullable<T> {
99
export function doesNotHaveValue<T>(value: T): value is Extract<T, null | undefined> {
1010
return value === null || value === undefined;
1111
}
12-
13-
export function valueOrDefault<T>(value: T | undefined, defaultValue: T): T {
14-
if (doesHaveValue(value)) {
15-
return value;
16-
}
17-
return defaultValue;
18-
}

src/reporter/cucumber/junit.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import junitFormatterPlugin from '@cucumber/junit-xml-formatter';
1010
import BaseReporter, { InternalOptions } from './base';
1111
import { GherkinDocumentMessage } from './messagesBuilder/GherkinDocument';
1212

13+
// title separator used in Playwright
14+
const PLAYWRIGHT_TITLE_SEPARATOR = ' › ';
15+
1316
type JunitReporterOptions = {
1417
outputFile?: string;
1518
suiteName?: string;
@@ -59,7 +62,7 @@ class PlaywrightNamingStrategy implements NamingStrategy {
5962
pickleName !== scenarioName ? pickleName : undefined,
6063
]
6164
.filter(Boolean)
62-
.join(' - ');
65+
.join(PLAYWRIGHT_TITLE_SEPARATOR);
6366
}
6467
}
6568

src/reporter/cucumber/messagesBuilder/Projects.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type ProjectInfo = {
1212
};
1313

1414
// title separator used in Playwright
15-
export const TITLE_SEPARATOR = ' › ';
15+
const PLAYWRIGHT_TITLE_SEPARATOR = ' › ';
1616

1717
const projectsMap = new AutofillMap<string | undefined, ProjectInfo>();
1818

@@ -47,5 +47,5 @@ export function getFeatureNameWithProject(
4747
projectName: ProjectInfo['projectName'],
4848
featureName: string,
4949
) {
50-
return projectName ? `${projectName}${TITLE_SEPARATOR}${featureName}` : featureName;
50+
return projectName ? `${projectName}${PLAYWRIGHT_TITLE_SEPARATOR}${featureName}` : featureName;
5151
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<?xml version="1.0"?>
22
<testsuite name="My suite" time="0.462010009" tests="6" skipped="0" failures="1" errors="0" timestamp="2025-06-04T06:38:01.423Z">
3-
<testcase classname="some feature" name="chromium - some feature - scenario with examples" time="0.018">
3+
<testcase classname="some feature" name="chromium some feature scenario with examples" time="0.018">
44
<system-out><![CDATA[Given success step 4........................................................passed]]></system-out>
55
</testcase>
6-
<testcase classname="some feature" name="chromium - some feature - scenario with examples" time="0.017">
6+
<testcase classname="some feature" name="chromium some feature scenario with examples" time="0.017">
77
<system-out><![CDATA[Given success step 2........................................................passed]]></system-out>
88
</testcase>
9-
<testcase classname="some feature" name="chromium - some feature - scenario with examples" time="0.018">
9+
<testcase classname="some feature" name="chromium some feature scenario with examples" time="0.018">
1010
<system-out><![CDATA[Given success step 3........................................................passed]]></system-out>
1111
</testcase>
12-
<testcase classname="some feature" name="chromium - some feature - success scenario" time="0.018">
12+
<testcase classname="some feature" name="chromium some feature success scenario" time="0.018">
1313
<system-out><![CDATA[Given success step 1........................................................passed
1414
And success step 2..........................................................passed]]></system-out>
1515
</testcase>
16-
<testcase classname="some feature" name="chromium - some feature - failing scenario" time="0.022">
16+
<testcase classname="some feature" name="chromium some feature failing scenario" time="0.022">
1717
<failure type="Error" message="Error: expect(received).toEqual(expected) // deep equality&#xA;&#xA;Expected: &quot;bar&quot;&#xA;Received: &quot;foo&quot;&#xA; at features/steps.ts:11&#xA;&#xA; 9 |&#xA; 10 | Given('failing step', async ({}) => {&#xA;> 11 | expect('foo').toEqual('bar');&#xA; | ^&#xA; 12 | });&#xA; 13 |"><![CDATA[ at Object.<anonymous> (/Users/vitalets/projects/playwright-bdd/test/reporter-cucumber-junit/features/steps.ts:11:17)
1818
at /Users/vitalets/projects/playwright-bdd/test/reporter-cucumber-junit/.features-gen/features/sample.feature.spec.js:13:5]]></failure>
1919
<system-out><![CDATA[Given success step 1........................................................passed
2020
And failing step............................................................failed]]></system-out>
2121
</testcase>
22-
<testcase classname="some feature" name="chromium - some feature - some rule - scenario with rule" time="0.002">
22+
<testcase classname="some feature" name="chromium some feature some rule scenario with rule" time="0.002">
2323
<system-out><![CDATA[Given success step 1........................................................passed]]></system-out>
2424
</testcase>
2525
</testsuite>
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<testsuite name="my suite" time="1.516464111" tests="9" skipped="0" failures="1" errors="0" timestamp="2026-03-27T08:27:49.482Z">
3-
<testcase classname="feature one" name="project one copy - feature one - scenario of project one" time="0.027">
3+
<testcase classname="feature one" name="project one copy feature one scenario of project one" time="0.027">
44
<failure type="Error" message="Error: expect(received).not.toEqual(expected) // deep equality&#xA;&#xA;Expected: not &quot;project one copy&quot;&#xA;&#xA; at features-one/steps/steps.ts:12&#xA;&#xA; 10 |&#xA; 11 | Given('Fails for project {string}', async ({ $testInfo }, projectName: string) => {&#xA;> 12 | expect($testInfo.project.name).not.toEqual(projectName);&#xA; | ^&#xA; 13 | });&#xA; 14 |"><![CDATA[ at Object.<anonymous> (/Users/vitalets/projects/playwright-bdd/test/reporter-cucumber-projects/features-one/steps/steps.ts:12:38)
55
at /Users/vitalets/projects/playwright-bdd/test/node_modules/playwright-bdd/src/runtime/bddStepInvoker.ts:59:60
66
at BddStepInvoker.invoke (/Users/vitalets/projects/playwright-bdd/test/node_modules/playwright-bdd/src/runtime/bddStepInvoker.ts:53:5)
@@ -9,36 +9,36 @@
99
And Fails for project "project one copy"....................................failed
1010
And TodoPage: step..........................................................skipped]]></system-out>
1111
</testcase>
12-
<testcase classname="feature one" name="project one copy - feature one - scenario with examples" time="0.019">
12+
<testcase classname="feature one" name="project one copy feature one scenario with examples" time="0.019">
1313
<system-out><![CDATA[Given State 2...............................................................passed
1414
And State 4.................................................................passed]]></system-out>
1515
</testcase>
16-
<testcase classname="feature one" name="project one copy - feature one - scenario with examples" time="0.005">
16+
<testcase classname="feature one" name="project one copy feature one scenario with examples" time="0.005">
1717
<system-out><![CDATA[Given State 3...............................................................passed
1818
And State 6.................................................................passed]]></system-out>
1919
</testcase>
20-
<testcase classname="feature one" name="project one copy - feature one - scenario with examples" time="0.005">
20+
<testcase classname="feature one" name="project one copy feature one scenario with examples" time="0.005">
2121
<system-out><![CDATA[Given State 4...............................................................passed
2222
And State 8.................................................................passed]]></system-out>
2323
</testcase>
24-
<testcase classname="feature one" name="project one - feature one - scenario of project one" time="0.023">
24+
<testcase classname="feature one" name="project one feature one scenario of project one" time="0.023">
2525
<system-out><![CDATA[Given State 1...............................................................passed
2626
And Fails for project "project one copy"....................................passed
2727
And TodoPage: step..........................................................passed]]></system-out>
2828
</testcase>
29-
<testcase classname="feature one" name="project one - feature one - scenario with examples" time="0.008">
29+
<testcase classname="feature one" name="project one feature one scenario with examples" time="0.008">
3030
<system-out><![CDATA[Given State 2...............................................................passed
3131
And State 4.................................................................passed]]></system-out>
3232
</testcase>
33-
<testcase classname="feature one" name="project one - feature one - scenario with examples" time="0.006">
33+
<testcase classname="feature one" name="project one feature one scenario with examples" time="0.006">
3434
<system-out><![CDATA[Given State 3...............................................................passed
3535
And State 6.................................................................passed]]></system-out>
3636
</testcase>
37-
<testcase classname="feature one" name="project one - feature one - scenario with examples" time="0.002">
37+
<testcase classname="feature one" name="project one feature one scenario with examples" time="0.002">
3838
<system-out><![CDATA[Given State 4...............................................................passed
3939
And State 8.................................................................passed]]></system-out>
4040
</testcase>
41-
<testcase classname="feature two" name="project two - feature two - scenario of project two" time="0.026">
41+
<testcase classname="feature two" name="project two feature two scenario of project two" time="0.026">
4242
<system-out><![CDATA[Given Another state 1.......................................................passed]]></system-out>
4343
</testcase>
4444
</testsuite>

0 commit comments

Comments
 (0)