Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b0201a4

Browse filesBrowse files
authored
enable cross-browser testing in cucumber reporter (via #737)
1 parent a7e8fb2 commit b0201a4
Copy full SHA for b0201a4

File tree

Expand file treeCollapse file tree

3 files changed

+33
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+33
-2
lines changed

‎packages/allure-cucumberjs/README.md

Copy file name to clipboardExpand all lines: packages/allure-cucumberjs/README.md
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,17 @@ Given(/my step/, async function () {
208208
});
209209
});
210210
```
211+
212+
## Cross-browser testing
213+
214+
For cross-browser testing simply add a parameter using Allure API with the browser name to the `World` instance inside your scenario, i.e.:
215+
216+
```js
217+
await this.parameter('Browser', 'firefox')
218+
```
219+
220+
For better presentation, you can also group suites by browser names, i.e.:
221+
222+
```js
223+
await this.parentSuite('Firefox')
224+
```

‎packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts

Copy file name to clipboardExpand all lines: packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ export class CucumberJSAllureFormatter extends Formatter {
506506
currentTest.status = Status.PASSED;
507507
}
508508

509+
currentTest.calculateHistoryId();
509510
currentTest.endTest(Date.now());
510511

511512
this.currentTestsMap.delete(data.testCaseStartedId);

‎packages/allure-cucumberjs/test/specs/simple_test.ts

Copy file name to clipboardExpand all lines: packages/allure-cucumberjs/test/specs/simple_test.ts
+18-2Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ const dataSet: { [name: string]: ITestFormatterOptions } = {
2929
},
3030
],
3131
},
32+
parameterized: {
33+
supportCodeLibrary: buildSupportCodeLibrary(({ Given }) => {
34+
Given("a step", function () {
35+
this.parameter("Browser", "firefox");
36+
});
37+
}),
38+
sources: [
39+
{
40+
data: ["Feature: a", "Scenario: b", "Given a step"].join("\n"),
41+
uri: "a.feature",
42+
},
43+
],
44+
},
3245
};
3346

3447
describe("CucumberJSAllureReporter > simple", () => {
@@ -76,17 +89,20 @@ describe("CucumberJSAllureReporter > simple", () => {
7689
});
7790

7891
it("sets fullName, testCaseId and historyId", async () => {
79-
const results = await runFeatures(dataSet.passed);
92+
const results = await runFeatures(dataSet.parameterized);
8093

8194
expect(results.tests).length(1);
8295
const [testResult] = results.tests;
8396
const source = dataSet.passed.sources?.[0];
8497

8598
const name = source!.data.match(/\nScenario: (.+)\n/)?.[1];
8699
const fullName = `${source!.uri}#${name!}`;
100+
const { name: paramName, value: paramValue } = testResult.parameters[0];
101+
const paramsHash = md5(`${paramName}:${paramValue}`);
102+
const historyId = `${testResult.testCaseId}:${paramsHash}`;
87103
expect(testResult.fullName).eq(fullName);
88104
expect(testResult.testCaseId).eq(md5(fullName));
89-
expect(testResult.historyId).eq(testResult.testCaseId);
105+
expect(testResult.historyId).eq(historyId);
90106
});
91107
});
92108

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.