diff --git a/packages/allure-cucumberjs/README.md b/packages/allure-cucumberjs/README.md index c7ef1354e..2fe789ee9 100644 --- a/packages/allure-cucumberjs/README.md +++ b/packages/allure-cucumberjs/README.md @@ -208,3 +208,17 @@ Given(/my step/, async function () { }); }); ``` + +## Cross-browser testing + +For cross-browser testing simply add a parameter using Allure API with the browser name to the `World` instance inside your scenario, i.e.: + +```js +await this.parameter('Browser', 'firefox') +``` + +For better presentation, you can also group suites by browser names, i.e.: + +```js +await this.parentSuite('Firefox') +``` diff --git a/packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts b/packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts index d0d18ed85..fbca224c4 100644 --- a/packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts +++ b/packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts @@ -506,6 +506,7 @@ export class CucumberJSAllureFormatter extends Formatter { currentTest.status = Status.PASSED; } + currentTest.calculateHistoryId(); currentTest.endTest(Date.now()); this.currentTestsMap.delete(data.testCaseStartedId); diff --git a/packages/allure-cucumberjs/test/specs/simple_test.ts b/packages/allure-cucumberjs/test/specs/simple_test.ts index adc79e511..2ba1cba2d 100644 --- a/packages/allure-cucumberjs/test/specs/simple_test.ts +++ b/packages/allure-cucumberjs/test/specs/simple_test.ts @@ -29,6 +29,19 @@ const dataSet: { [name: string]: ITestFormatterOptions } = { }, ], }, + parameterized: { + supportCodeLibrary: buildSupportCodeLibrary(({ Given }) => { + Given("a step", function () { + this.parameter("Browser", "firefox"); + }); + }), + sources: [ + { + data: ["Feature: a", "Scenario: b", "Given a step"].join("\n"), + uri: "a.feature", + }, + ], + }, }; describe("CucumberJSAllureReporter > simple", () => { @@ -76,7 +89,7 @@ describe("CucumberJSAllureReporter > simple", () => { }); it("sets fullName, testCaseId and historyId", async () => { - const results = await runFeatures(dataSet.passed); + const results = await runFeatures(dataSet.parameterized); expect(results.tests).length(1); const [testResult] = results.tests; @@ -84,9 +97,12 @@ describe("CucumberJSAllureReporter > simple", () => { const name = source!.data.match(/\nScenario: (.+)\n/)?.[1]; const fullName = `${source!.uri}#${name!}`; + const { name: paramName, value: paramValue } = testResult.parameters[0]; + const paramsHash = md5(`${paramName}:${paramValue}`); + const historyId = `${testResult.testCaseId}:${paramsHash}`; expect(testResult.fullName).eq(fullName); expect(testResult.testCaseId).eq(md5(fullName)); - expect(testResult.historyId).eq(testResult.testCaseId); + expect(testResult.historyId).eq(historyId); }); });