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.2.1
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.3.0
Choose a head ref
  • 7 commits
  • 49 files changed
  • 4 contributors

Commits on May 2, 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
    1d4d860 View commit details

Commits on May 8, 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
    6c567df View commit details

Commits on May 10, 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
    7e70a60 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
    45a53b9 View commit details

Commits on May 11, 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
    5cbdafe 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
    758af40 View commit details
  3. release 2.3.0

    qameta-ci committed May 11, 2023
    Copy the full SHA
    1e8dc97 View commit details
Showing with 1,935 additions and 517 deletions.
  1. +11 −5 .github/workflows/build.yml
  2. +1 −1 package.json
  3. +1 −1 packages/allure-codeceptjs/package.json
  4. +1 −1 packages/allure-cucumberjs/package.json
  5. +1 −1 packages/allure-decorators/package.json
  6. +1 −1 packages/allure-hermione/package.json
  7. +58 −44 packages/allure-hermione/src/index.ts
  8. +1 −0 packages/allure-hermione/test/.hermione.conf.js
  9. +1 −1 packages/allure-hermione/test/runner.ts
  10. +1 −1 packages/allure-jasmine/package.json
  11. +1 −1 packages/allure-jest/package.json
  12. +6 −1 packages/allure-js-commons/index.ts
  13. +2 −1 packages/allure-js-commons/package.json
  14. +1 −1 packages/allure-js-commons/src/AllureRuntime.ts
  15. +20 −0 packages/allure-js-commons/src/AllureTest.ts
  16. +1 −0 packages/allure-js-commons/src/properties.d.ts
  17. +15 −0 packages/allure-js-commons/src/utils.ts
  18. +3 −1 packages/allure-js-commons/src/writers/InMemoryAllureWriter.ts
  19. +58 −0 packages/allure-js-commons/src/writers/MessageAllureWriter.ts
  20. +1 −0 packages/allure-js-commons/src/writers/index.ts
  21. +904 −33 packages/allure-js-commons/src/writers/utils.ts
  22. +115 −1 packages/allure-js-commons/test/specs/utils.spec.ts
  23. +1 −1 packages/allure-mocha/package.json
  24. +1 −1 packages/allure-playwright/.gitignore
  25. +13 −0 packages/allure-playwright/README.md
  26. +3 −1 packages/allure-playwright/package.json
  27. +49 −32 packages/allure-playwright/src/index.ts
  28. +19 −0 packages/allure-playwright/src/utils.ts
  29. +16 −26 packages/allure-playwright/test/attachment.spec.ts
  30. +28 −33 packages/allure-playwright/test/categories.spec.ts
  31. +10 −15 packages/allure-playwright/test/environmentInfo.spec.ts
  32. +53 −21 packages/allure-playwright/test/fixtures.ts
  33. +26 −39 packages/allure-playwright/test/global-fail.spec.ts
  34. +13 −19 packages/allure-playwright/test/history.spec.ts
  35. +13 −12 packages/allure-playwright/test/label.spec.ts
  36. +65 −73 packages/allure-playwright/test/labels.spec.ts
  37. +18 −19 packages/allure-playwright/test/link.spec.ts
  38. +28 −11 packages/allure-playwright/test/parameters.spec.ts
  39. +22 −0 packages/allure-playwright/test/playwright.config.ts
  40. +9 −15 packages/allure-playwright/test/skip.test.ts
  41. +11 −11 packages/allure-playwright/test/status-details.spec.ts
  42. +11 −9 packages/allure-playwright/test/status.spec.ts
  43. +63 −22 packages/allure-playwright/test/stdio.spec.ts
  44. +85 −40 packages/allure-playwright/test/steps.spec.ts
  45. +16 −15 packages/allure-playwright/test/tags.spec.ts
  46. +1 −6 packages/allure-playwright/test/testplan.spec.ts
  47. +22 −0 packages/allure-playwright/test/title-metadata.spec.ts
  48. +1 −1 packages/newman-reporter-allure/package.json
  49. +134 −0 yarn.lock
16 changes: 11 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -4,11 +4,11 @@ on:
workflow_dispatch:
pull_request:
branches:
- '*'
- "*"
push:
branches:
- 'master'
- 'hotfix-*'
- "master"
- "hotfix-*"

jobs:
build:
@@ -25,7 +25,14 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
cache: "yarn"

- name: Cache Hermione Browsers
uses: actions/cache@v3
with:
key: "default"
path: |
~/hermione-headless-chrome
- name: yarn install
run: |
@@ -45,4 +52,3 @@ jobs:
- name: yarn test
run: |
yarn run test
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.2.1",
"version": "2.3.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.2.1",
"version": "2.3.0",
"description": "Allure codeceptjs integration",
"license": "Apache-2.0",
"repository": {
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.2.1",
"version": "2.3.0",
"description": "Allure Cucumber.JS integration",
"license": "Apache-2.0",
"author": {
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.2.1",
"version": "2.3.0",
"description": "Write your tests in a Java-like annotation-driven manner via JS decorators.",
"license": "Apache-2.0",
"author": {
2 changes: 1 addition & 1 deletion packages/allure-hermione/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allure-hermione",
"version": "2.2.1",
"version": "2.3.0",
"packageManager": "yarn@3.4.1",
"license": "Apache-2.0",
"author": {
102 changes: 58 additions & 44 deletions packages/allure-hermione/src/index.ts
Original file line number Diff line number Diff line change
@@ -45,8 +45,16 @@ const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) =
resultsDir: "allure-results",
...opts,
});
const getTestId = (context: string | Hermione.Test) => {
if (typeof context === "string") {
return (testId?: string) => `${context}:${testId || ""}`;
}

return () => `${context.sessionId}:${context.id()}`;
};
const handleTestError = (test: Hermione.Test, error: Hermione.TestError) => {
const currentTest = runningTests.get(test.id())!;
const testId = getTestId(test);
const currentTest = runningTests.get(testId())!;
const { message, stack, screenshot } = error;

currentTest.detailsMessage = message;
@@ -139,63 +147,65 @@ const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) =
};

hermione.on(hermione.events.NEW_BROWSER, (browser) => {
browser.addCommand("label", async (testId: string, name: string, value: string) => {
await addLabel(testId, name, value);
const testId = getTestId(browser.sessionId);

browser.addCommand("label", async (id: string, name: string, value: string) => {
await addLabel(testId(id), name, value);
});
browser.addCommand("link", async (id: string, url: string, name?: string, type?: string) => {
await addLink(testId(id), url, name, type);
});
browser.addCommand(
"link",
async (testId: string, url: string, name?: string, type?: string) => {
await addLink(testId, url, name, type);
},
);
browser.addCommand(
"parameter",
async (testId: string, name: string, value: string, options?: ParameterOptions) => {
await addParameter(testId, name, value, options);
async (id: string, name: string, value: string, options?: ParameterOptions) => {
await addParameter(testId(id), name, value, options);
},
);
browser.addCommand("id", async (testId: string, value: string) => {
await addLabel(testId, LabelName.ALLURE_ID, value);
browser.addCommand("id", async (id: string, value: string) => {
await addLabel(testId(id), LabelName.ALLURE_ID, value);
});
browser.addCommand("epic", async (testId: string, value: string) => {
await addLabel(testId, LabelName.EPIC, value);
browser.addCommand("epic", async (id: string, value: string) => {
await addLabel(testId(id), LabelName.EPIC, value);
});
browser.addCommand("feature", async (testId: string, value: string) => {
await addLabel(testId, LabelName.FEATURE, value);
browser.addCommand("feature", async (id: string, value: string) => {
await addLabel(testId(id), LabelName.FEATURE, value);
});
browser.addCommand("story", async (testId: string, value: string) => {
await addLabel(testId, LabelName.STORY, value);
browser.addCommand("story", async (id: string, value: string) => {
await addLabel(testId(id), LabelName.STORY, value);
});
browser.addCommand("suite", async (testId: string, value: string) => {
await addLabel(testId, LabelName.SUITE, value);
browser.addCommand("suite", async (id: string, value: string) => {
await addLabel(testId(id), LabelName.SUITE, value);
});
browser.addCommand("parentSuite", async (testId: string, value: string) => {
await addLabel(testId, LabelName.PARENT_SUITE, value);
browser.addCommand("parentSuite", async (id: string, value: string) => {
await addLabel(testId(id), LabelName.PARENT_SUITE, value);
});
browser.addCommand("subSuite", async (testId: string, value: string) => {
await addLabel(testId, LabelName.SUB_SUITE, value);
browser.addCommand("subSuite", async (id: string, value: string) => {
await addLabel(testId(id), LabelName.SUB_SUITE, value);
});
browser.addCommand("owner", async (testId: string, value: string) => {
await addLabel(testId, LabelName.OWNER, value);
browser.addCommand("owner", async (id: string, value: string) => {
await addLabel(testId(id), LabelName.OWNER, value);
});
browser.addCommand("severity", async (testId: string, value: string) => {
await addLabel(testId, LabelName.SEVERITY, value);
browser.addCommand("severity", async (id: string, value: string) => {
await addLabel(testId(id), LabelName.SEVERITY, value);
});
browser.addCommand("tag", async (testId: string, value: string) => {
await addLabel(testId, LabelName.TAG, value);
browser.addCommand("tag", async (id: string, value: string) => {
await addLabel(testId(id), LabelName.TAG, value);
});
browser.addCommand("issue", async (testId: string, name: string, url: string) => {
await addLink(testId, url, name, LinkType.ISSUE);
browser.addCommand("issue", async (id: string, name: string, url: string) => {
await addLink(testId(id), url, name, LinkType.ISSUE);
});
browser.addCommand("tms", async (testId: string, name: string, url: string) => {
await addLink(testId, url, name, LinkType.TMS);
browser.addCommand("tms", async (id: string, name: string, url: string) => {
await addLink(testId(id), url, name, LinkType.TMS);
});
browser.addCommand("attach", async (testId: string, source: string, mimetype: string) => {
await addAttachment(testId, source, mimetype);
browser.addCommand("attach", async (id: string, source: string, mimetype: string) => {
await addAttachment(testId(id), source, mimetype);
});
browser.addCommand("step", async (testId: string, name: string, body: StepBodyFunction) => {
browser.addCommand("step", async (id: string, name: string, body: StepBodyFunction) => {
const step = new AllureCommandStepExecutable(name);
await step.run(body, async (message: MetadataMessage) => await sendMetadata(testId, message));
await step.run(
body,
async (message: MetadataMessage) => await sendMetadata(testId(id), message),
);
});
});
hermione.on(hermione.events.NEW_WORKER_PROCESS, (worker) => {
@@ -210,6 +220,7 @@ const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) =
});
});
hermione.on(hermione.events.TEST_BEGIN, (test) => {
const testId = getTestId(test);
const { ALLURE_HOST_NAME, ALLURE_THREAD_NAME } = process.env;
const thread = ALLURE_THREAD_NAME || test.sessionId;
const hostnameLabel = ALLURE_HOST_NAME || hostname;
@@ -238,15 +249,17 @@ const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) =
currentTest.addLabel(LabelName.SUB_SUITE, subSuites.join(" > "));
}

runningTests.set(test.id(), currentTest);
runningTests.set(testId(), currentTest);
});
hermione.on(hermione.events.TEST_PASS, (test) => {
const currentTest = runningTests.get(test.id())!;
const testId = getTestId(test);
const currentTest = runningTests.get(testId())!;

currentTest.status = Status.PASSED;
});
hermione.on(hermione.events.TEST_FAIL, (test) => {
const currentTest = runningTests.get(test.id());
const testId = getTestId(test);
const currentTest = runningTests.get(testId());

// hermione handle all errors in this hook, even test hasn't been started
if (!currentTest) {
@@ -256,15 +269,16 @@ const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) =
currentTest.status = Status.FAILED;
});
hermione.on(hermione.events.TEST_END, (test) => {
const currentTest = runningTests.get(test.id())!;
const testId = getTestId(test);
const currentTest = runningTests.get(testId())!;

if (test.err) {
handleTestError(test, test.err);
}

currentTest.stage = Stage.FINISHED;
currentTest.endTest(Date.now());
runningTests.delete(test.id());
runningTests.delete(testId());
});

// it needs for tests because we need to read runtime writer data redefined in hermione config
1 change: 1 addition & 0 deletions packages/allure-hermione/test/.hermione.conf.js
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ module.exports = {
"hermione-headless-chrome": {
enabled: true,
browserId: "headless",
version: "112",
},
"allure-hermione": {
writer: {
2 changes: 1 addition & 1 deletion packages/allure-hermione/test/runner.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import Mocha from "mocha";
import "source-map-support/register";

const mocha = new Mocha({
timeout: 16000,
timeout: 30000,
reporter: "mocha-multi-reporters",
reporterOptions: {
reporterEnabled: "list, ../allure-mocha",
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.2.1",
"version": "2.3.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.2.1",
"version": "2.3.0",
"description": "Allure Jest integration",
"license": "Apache-2.0",
"author": {
7 changes: 6 additions & 1 deletion packages/allure-js-commons/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
export { AllureRuntime } from "./src/AllureRuntime";
export { InMemoryAllureWriter, FileSystemAllureWriter, AllureResults } from "./src/writers";
export {
InMemoryAllureWriter,
FileSystemAllureWriter,
MessageAllureWriter,
AllureResults
} from "./src/writers";
export { AllureConfig } from "./src/AllureConfig";
export { AllureGroup } from "./src/AllureGroup";
export { ExecutableItemWrapper } from "./src/ExecutableItemWrapper";
3 changes: 2 additions & 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.2.1",
"version": "2.3.0",
"description": "Allure JS Commons",
"license": "Apache-2.0",
"author": {
@@ -42,6 +42,7 @@
"@types/uuid": "^8.3.0",
"allure-mocha": "workspace:packages/allure-mocha",
"chai": "^4.3.4",
"expect": "^29.5.0",
"glob": "^8.0.0",
"mocha": "^9.1.3",
"mocha-multi-reporters": "^1.5.1",
2 changes: 1 addition & 1 deletion packages/allure-js-commons/src/AllureRuntime.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ const buildAttachmentFileName = (options: ContentType | string | AttachmentOptio
options = { contentType: options };
}
const extension = typeToExtension(options);
return `${randomUUID()}-attachment.${extension}`;
return `${randomUUID()}-attachment${extension}`;
};

export class AllureRuntime {
20 changes: 20 additions & 0 deletions packages/allure-js-commons/src/AllureTest.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import { AllureRuntime } from "./AllureRuntime";
import { testResult } from "./constructors";
import { ExecutableItemWrapper } from "./ExecutableItemWrapper";
import { LinkType, TestResult } from "./model";
import { md5 } from "./utils";

export class AllureTest extends ExecutableItemWrapper {
private readonly testResult: TestResult;
@@ -49,4 +50,23 @@ export class AllureTest extends ExecutableItemWrapper {
addTmsLink(url: string, name: string): void {
this.addLink(url, name, LinkType.TMS);
}

calculateHistoryId(): void {
const tcId = this.testResult.testCaseId
? this.testResult.testCaseId
: this.testResult.fullName
? md5(this.testResult.fullName)
: null;

if (tcId) {
const paramsString = this.testResult.parameters
.filter((p) => !p?.excluded)
.sort((a, b) => a.name?.localeCompare(b?.name) || a.value?.localeCompare(b?.value))
.map((p) => `${p.name ?? "null"}:${p.value ?? "null"}`)
.join(",");

const paramsHash = md5(paramsString);
this.historyId = `${tcId}:${paramsHash}`;
}
}
}
1 change: 1 addition & 0 deletions packages/allure-js-commons/src/properties.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare module "properties" {
function parse(data: string, options?: Config): Record<string, any> | undefined;
function stringify(obj: any, options?: Config): string;
function stringify(obj: any, options: Config, callback: () => void): undefined;

15 changes: 15 additions & 0 deletions packages/allure-js-commons/src/utils.ts
Original file line number Diff line number Diff line change
@@ -80,3 +80,18 @@ export const defaultReportFolder = (): string => {

export const allureIdRegexp = /^@?allure.id[:=](?<id>.+)$/;
export const allureLabelRegexp = /@?allure.label.(?<name>.+?)[:=](?<value>.+)/;

export const getStatusFromError = (error: Error): Status => {
switch (true) {
/**
* Native `node:assert` and `chai` (`vitest` uses it under the hood) throw `AssertionError`
* `jest` throws `JestAssertionError` instance
*/
case /assert/gi.test(error.constructor.name):
case /assert/gi.test(error.name):
case /assert/gi.test(error.message):
return Status.FAILED;
default:
return Status.BROKEN;
}
};
Original file line number Diff line number Diff line change
@@ -6,9 +6,11 @@ export interface AllureResults {
tests: TestResult[];
groups: TestResultContainer[];
attachments: Record<string, Buffer | string>;
envInfo?: Record<string, string | undefined>;
categories?: Category[];
}

export class InMemoryAllureWriter implements AllureWriter {
export class InMemoryAllureWriter implements AllureWriter, AllureResults {
public groups: TestResultContainer[] = [];
public tests: TestResult[] = [];
public attachments: Record<string, Buffer | string> = {};
Loading