Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: allure-framework/allure-js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.3.0
Choose a base ref
...
head repository: allure-framework/allure-js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.4.0
Choose a head ref
  • 5 commits
  • 26 files changed
  • 5 contributors

Commits on May 24, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    72bc7e2 View commit details

Commits on May 26, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f38b1e8 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9db5b82 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3a49189 View commit details
  4. release 2.4.0

    qameta-ci committed May 26, 2023
    Copy the full SHA
    224e6ce View commit details
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ module.exports = {
"@typescript-eslint",
],
rules: {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": [
"error",
@@ -216,7 +217,7 @@ module.exports = {
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-underscore-dangle": "error",
"no-underscore-dangle": ["error", { "allow": ["_currentRetry", "_retriedTest", "_retries"] }],
"no-unsafe-finally": "error",
"no-unused-labels": "error",
"no-var": "error",
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "allure-js",
"private": true,
"version": "2.3.0",
"version": "2.4.0",
"workspaces": [
"packages/*"
],
2 changes: 1 addition & 1 deletion packages/allure-codeceptjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allure-codeceptjs",
"version": "2.3.0",
"version": "2.4.0",
"description": "Allure codeceptjs integration",
"license": "Apache-2.0",
"repository": {
12 changes: 10 additions & 2 deletions packages/allure-codeceptjs/src/index.ts
Original file line number Diff line number Diff line change
@@ -208,11 +208,19 @@ class AllureReporter {
}

testAfter(test: CodeceptTest) {
// @ts-ignore
const currentRetry = test._currentRetry;
if (currentRetry !== 0) {
// @ts-ignore
test = test._retriedTest;
}
const allureTest = this.allureTestByCodeceptTest(test);

allureTest?.endTest();

this.currentTest = null;
// @ts-ignore
if (test.state === "failed" && test._retries !== 0 && currentRetry !== test._retries) {
this.createTest(test);
}
}

getStepParents(step: CodeceptStep) {
47 changes: 47 additions & 0 deletions packages/allure-codeceptjs/test/retries.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const allurePlugin = require("../src/index.ts");
describe("handleRetries", () => {
it("should handle retries if the test has retried", () => {
// Mock the necessary dependencies and setup test data
const test = {
_currentRetry: 1,
_retriedTest: {
state: "failed",
_retries: 2,
},
};

const allureTestByCodeceptTest = jest.fn().mockReturnValue({
endTest: jest.fn(),
});
const createTest = jest.fn();

const instance = allurePlugin({ outputDir: "./output" });
instance.allureTestByCodeceptTest = allureTestByCodeceptTest;
instance.createTest = createTest;

instance.testAfter(test);

expect(allureTestByCodeceptTest).toHaveBeenCalledWith(test._retriedTest);
expect(allureTestByCodeceptTest().endTest).toHaveBeenCalled();
expect(createTest).toHaveBeenCalledWith(test._retriedTest);
});

it("should not handle retries if the test has not retried", () => {
// Mock the necessary dependencies and setup test data
const test = {
_currentRetry: 0,
_retriedTest: {},
};

const allureTestByCodeceptTest = jest.fn();
const createTest = jest.fn();

const instance = allurePlugin({ outputDir: "./output" });
instance.allureTestByCodeceptTest = allureTestByCodeceptTest;
instance.createTest = createTest;

instance.testAfter(test);

expect(createTest).not.toHaveBeenCalled();
});
});
2 changes: 1 addition & 1 deletion packages/allure-cucumberjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allure-cucumberjs",
"version": "2.3.0",
"version": "2.4.0",
"description": "Allure Cucumber.JS integration",
"license": "Apache-2.0",
"author": {
2 changes: 1 addition & 1 deletion packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts
Original file line number Diff line number Diff line change
@@ -385,7 +385,7 @@ export class CucumberJSAllureFormatter extends Formatter {
const encoding = Buffer.isEncoding(contentEncoding) ? contentEncoding : undefined; // only pass through valid encodings
const attachmentFilename = this.allureRuntime.writeAttachment(body, mediaType, encoding);

currentTest.addAttachment(
(currentStep ?? currentTest).addAttachment(
fileName,
{
contentType: mediaType,
4 changes: 2 additions & 2 deletions packages/allure-cucumberjs/test/specs/attachments_test.ts
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ describe("CucumberJSAllureReporter > examples", () => {
expect(attachmentsKeys).length(2);
expect(results.attachments[attachmentsKeys[0]]).eq("some text");

const [attachment] = results.tests[0].attachments;
const [attachment] = results.tests[0].steps[0].attachments;
expect(attachment.type).eq("text/plain");
expect(attachment.source).eq(attachmentsKeys[0]);
});
@@ -58,7 +58,7 @@ describe("CucumberJSAllureReporter > examples", () => {
const attachmentsKeys = Object.keys(results.attachments);
expect(attachmentsKeys).length(2);

const [imageAttachment] = results.tests[1].attachments;
const [imageAttachment] = results.tests[1].steps[0].attachments;
expect(imageAttachment.type).eq("image/png");
});
});
2 changes: 1 addition & 1 deletion packages/allure-decorators/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allure-decorators",
"version": "2.3.0",
"version": "2.4.0",
"description": "Write your tests in a Java-like annotation-driven manner via JS decorators.",
"license": "Apache-2.0",
"author": {
43 changes: 43 additions & 0 deletions packages/allure-hermione/docs/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Development

## Running hermione tests locally

The easiest way to run Hermione tests locally is [Selenium standalone grid](https://www.npmjs.com/package/selenium-standalone).

```shell
npm i -g selenium-standalone # install the package globally
selenium-standalone install # install selenium server
selenium-standalone start # start selenium server
```

Then you are able to run Hermione tests with the following settings:

```js
// .hermione.conf.js
module.exports = {
gridUrl: "http://localhost:4444/wd/hub",
// ...
};
```

Tests in the package already runs the grid before themselves, so you don't need to start it manually.

## Using repeater

To test the reporter with `hermione-test-repeater`, install `hermione-test-repeater` package and
add the following configuration to your `.hermione.conf.js`:

```js
module.exports = {
// ...
plugins: {
"hermione-test-repeater": {
enabled: true,
repeat: 10,
minRepeat: 10,
maxRepeat: 100,
uniqSession: true,
},
},
};
```
5 changes: 3 additions & 2 deletions packages/allure-hermione/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allure-hermione",
"version": "2.3.0",
"version": "2.4.0",
"packageManager": "yarn@3.4.1",
"license": "Apache-2.0",
"author": {
@@ -33,17 +33,18 @@
"@types/glob": "^7.1.4",
"@types/mocha": "^10.0.0",
"@types/node": "^16.7.8",
"@types/selenium-standalone": "^7.0.1",
"chai": "^4.2.0",
"codecov": "^3.6.5",
"dotenv": "^10.0.0",
"fs-jetpack": "^4.1.0",
"glob": "^7.1.7",
"hermione": "^6.0.2",
"hermione-headless-chrome": "^1.1.0",
"mocha": "^9.1.3",
"mocha-multi-reporters": "^1.5.1",
"nyc": "^15.0.1",
"rimraf": "^3.0.2",
"selenium-standalone": "^8.3.0",
"source-map-support": "^0.5.19",
"ts-node": "^10.2.1",
"typescript": "^4.4.2"
21 changes: 17 additions & 4 deletions packages/allure-hermione/src/index.ts
Original file line number Diff line number Diff line change
@@ -37,6 +37,8 @@ export type AllureReportOptions = {
resultsDir?: string;
};

export type TestIDFactory = (testId?: string) => string;

const hostname = os.hostname();

const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) => {
@@ -45,12 +47,18 @@ const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) =
resultsDir: "allure-results",
...opts,
});
const getTestId = (context: string | Hermione.Test) => {
/**
* Creates browser-specific test ID to identify test in the reporter
*
* @param context Hermione test object, or browser ID string
* @returns Browser-specific test ID factory function
*/
const getTestId = (context: string | Hermione.Test): TestIDFactory => {
if (typeof context === "string") {
return (testId?: string) => `${context}:${testId || ""}`;
}

return () => `${context.sessionId}:${context.id()}`;
return () => `${context.browserId}:${context.id()}`;
};
const handleTestError = (test: Hermione.Test, error: Hermione.TestError) => {
const testId = getTestId(test);
@@ -146,8 +154,8 @@ const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) =
currentTest.addStep(step);
};

hermione.on(hermione.events.NEW_BROWSER, (browser) => {
const testId = getTestId(browser.sessionId);
hermione.on(hermione.events.NEW_BROWSER, (browser, { browserId }) => {
const testId = getTestId(browserId);

browser.addCommand("label", async (id: string, name: string, value: string) => {
await addLabel(testId(id), name, value);
@@ -220,6 +228,10 @@ const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) =
});
});
hermione.on(hermione.events.TEST_BEGIN, (test) => {
if (!test.sessionId) {
throw new Error("Test session hasn't been started correctly! Check the driver availability.");
}

const testId = getTestId(test);
const { ALLURE_HOST_NAME, ALLURE_THREAD_NAME } = process.env;
const thread = ALLURE_THREAD_NAME || test.sessionId;
@@ -236,6 +248,7 @@ const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) =
currentTest.addLabel(LabelName.LANGUAGE, "javascript");
currentTest.addLabel(LabelName.FRAMEWORK, "hermione");
currentTest.addLabel(LabelName.THREAD, thread);
currentTest.addParameter("browser", test.browserId);

if (parentSuite) {
currentTest.addLabel(LabelName.PARENT_SUITE, parentSuite);
7 changes: 1 addition & 6 deletions packages/allure-hermione/test/.hermione.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
gridUrl: "http://localhost:4444/wd/hub",
sets: {
desktop: {
browsers: ["headless"],
@@ -7,7 +8,6 @@ module.exports = {
},
browsers: {
headless: {
automationProtocol: "devtools",
desiredCapabilities: {
browserName: "chrome",
"goog:chromeOptions": {
@@ -17,11 +17,6 @@ module.exports = {
},
},
plugins: {
"hermione-headless-chrome": {
enabled: true,
browserId: "headless",
version: "112",
},
"allure-hermione": {
writer: {
results: [],
31 changes: 20 additions & 11 deletions packages/allure-hermione/test/runner.ts
Original file line number Diff line number Diff line change
@@ -3,19 +3,28 @@
import path from "path";
import glob from "glob";
import Mocha from "mocha";
import selenium from "selenium-standalone";
import "source-map-support/register";

const mocha = new Mocha({
timeout: 30000,
reporter: "mocha-multi-reporters",
reporterOptions: {
reporterEnabled: "list, ../allure-mocha",
allureMochaReporterOptions: {
resultsDir: path.resolve(__dirname, "../out/allure-results"),
(async () => {
await selenium.install();

const seleniumProcess = await selenium.start();
const mocha = new Mocha({
timeout: 30000,
reporter: "mocha-multi-reporters",
reporterOptions: {
reporterEnabled: "list, ../allure-mocha",
allureMochaReporterOptions: {
resultsDir: path.resolve(__dirname, "../out/allure-results"),
},
},
},
});
});

glob.sync("./test/spec/**/*.test.ts").forEach((file) => mocha.addFile(file));
glob.sync("./test/spec/**/*.test.ts").forEach((file) => mocha.addFile(file));

mocha.run((failures) => process.exit(failures === 0 ? 0 : 1));
mocha.run((failures) => {
seleniumProcess.kill();
process.exit(failures === 0 ? 0 : 1);
});
})();
2 changes: 1 addition & 1 deletion packages/allure-jasmine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allure-jasmine",
"version": "2.3.0",
"version": "2.4.0",
"description": "Allure Jasmine integration",
"license": "Apache-2.0",
"author": {
2 changes: 1 addition & 1 deletion packages/allure-jest/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "allure-jest",
"version": "2.3.0",
"version": "2.4.0",
"description": "Allure Jest integration",
"license": "Apache-2.0",
"author": {
2 changes: 1 addition & 1 deletion packages/allure-js-commons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allure-js-commons",
"version": "2.3.0",
"version": "2.4.0",
"description": "Allure JS Commons",
"license": "Apache-2.0",
"author": {
2 changes: 1 addition & 1 deletion packages/allure-mocha/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allure-mocha",
"version": "2.3.0",
"version": "2.4.0",
"description": "Allure Mocha integration",
"license": "Apache-2.0",
"author": {
4 changes: 2 additions & 2 deletions packages/allure-playwright/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allure-playwright",
"version": "2.3.0",
"version": "2.4.0",
"description": "Allure Playwright integration",
"license": "Apache-2.0",
"author": {
@@ -30,7 +30,7 @@
"lint:fix": "eslint ./src --ext .ts --fix"
},
"devDependencies": {
"@playwright/test": "^1.30.0",
"@playwright/test": "^1.34.1",
"properties": "^1.2.1",
"rimraf": "^3.0.2",
"typescript": "^4.4.2"
Loading