diff --git a/.yarn/sdks/eslint/bin/eslint.js b/.yarn/sdks/eslint/bin/eslint.js index 42eab9933..e6604ff59 100755 --- a/.yarn/sdks/eslint/bin/eslint.js +++ b/.yarn/sdks/eslint/bin/eslint.js @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); const absRequire = createRequire(absPnpApiPath); const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) { } } +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + // Defer to the real eslint/bin/eslint.js your application uses -module.exports = absRequire(`eslint/bin/eslint.js`); +module.exports = wrapWithUserWrapper(absRequire(`eslint/bin/eslint.js`)); diff --git a/.yarn/sdks/eslint/lib/api.js b/.yarn/sdks/eslint/lib/api.js index ea2b46a70..8addf97fb 100644 --- a/.yarn/sdks/eslint/lib/api.js +++ b/.yarn/sdks/eslint/lib/api.js @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); const absRequire = createRequire(absPnpApiPath); const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) { } } +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + // Defer to the real eslint your application uses -module.exports = absRequire(`eslint`); +module.exports = wrapWithUserWrapper(absRequire(`eslint`)); diff --git a/.yarn/sdks/eslint/lib/unsupported-api.js b/.yarn/sdks/eslint/lib/unsupported-api.js index f5f8e24d0..c2b464ce6 100644 --- a/.yarn/sdks/eslint/lib/unsupported-api.js +++ b/.yarn/sdks/eslint/lib/unsupported-api.js @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); const absRequire = createRequire(absPnpApiPath); const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) { } } +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + // Defer to the real eslint/use-at-your-own-risk your application uses -module.exports = absRequire(`eslint/use-at-your-own-risk`); +module.exports = wrapWithUserWrapper(absRequire(`eslint/use-at-your-own-risk`)); diff --git a/.yarn/sdks/prettier/bin/prettier.cjs b/.yarn/sdks/prettier/bin/prettier.cjs index 00f1f7f74..9a4098f7d 100755 --- a/.yarn/sdks/prettier/bin/prettier.cjs +++ b/.yarn/sdks/prettier/bin/prettier.cjs @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); const absRequire = createRequire(absPnpApiPath); const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) { } } +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + // Defer to the real prettier/bin/prettier.cjs your application uses -module.exports = absRequire(`prettier/bin/prettier.cjs`); +module.exports = wrapWithUserWrapper(absRequire(`prettier/bin/prettier.cjs`)); diff --git a/.yarn/sdks/prettier/index.cjs b/.yarn/sdks/prettier/index.cjs index d546c6a75..57cb2ab17 100644 --- a/.yarn/sdks/prettier/index.cjs +++ b/.yarn/sdks/prettier/index.cjs @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`); const relPnpApiPath = "../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); const absRequire = createRequire(absPnpApiPath); const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) { } } +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + // Defer to the real prettier your application uses -module.exports = absRequire(`prettier`); +module.exports = wrapWithUserWrapper(absRequire(`prettier`)); diff --git a/.yarn/sdks/typescript/bin/tsc b/.yarn/sdks/typescript/bin/tsc index a6bb0e2c1..867a7bdfe 100755 --- a/.yarn/sdks/typescript/bin/tsc +++ b/.yarn/sdks/typescript/bin/tsc @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); const absRequire = createRequire(absPnpApiPath); const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) { } } +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + // Defer to the real typescript/bin/tsc your application uses -module.exports = absRequire(`typescript/bin/tsc`); +module.exports = wrapWithUserWrapper(absRequire(`typescript/bin/tsc`)); diff --git a/.yarn/sdks/typescript/bin/tsserver b/.yarn/sdks/typescript/bin/tsserver index 957bed200..3fc5aa31c 100755 --- a/.yarn/sdks/typescript/bin/tsserver +++ b/.yarn/sdks/typescript/bin/tsserver @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); const absRequire = createRequire(absPnpApiPath); const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) { } } +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + // Defer to the real typescript/bin/tsserver your application uses -module.exports = absRequire(`typescript/bin/tsserver`); +module.exports = wrapWithUserWrapper(absRequire(`typescript/bin/tsserver`)); diff --git a/.yarn/sdks/typescript/lib/tsc.js b/.yarn/sdks/typescript/lib/tsc.js index a262a77d0..da411bdba 100644 --- a/.yarn/sdks/typescript/lib/tsc.js +++ b/.yarn/sdks/typescript/lib/tsc.js @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); const absRequire = createRequire(absPnpApiPath); const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) { } } +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + // Defer to the real typescript/lib/tsc.js your application uses -module.exports = absRequire(`typescript/lib/tsc.js`); +module.exports = wrapWithUserWrapper(absRequire(`typescript/lib/tsc.js`)); diff --git a/.yarn/sdks/typescript/lib/tsserver.js b/.yarn/sdks/typescript/lib/tsserver.js index 1dae54c1a..6249c4675 100644 --- a/.yarn/sdks/typescript/lib/tsserver.js +++ b/.yarn/sdks/typescript/lib/tsserver.js @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); const absRequire = createRequire(absPnpApiPath); const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); @@ -23,7 +24,15 @@ if (existsSync(absPnpApiPath)) { } } -const moduleWrapper = tsserver => { +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + +const moduleWrapper = exports => { + return wrapWithUserWrapper(moduleWrapperFn(exports)); +}; + +const moduleWrapperFn = tsserver => { if (!process.versions.pnp) { return tsserver; } diff --git a/.yarn/sdks/typescript/lib/tsserverlibrary.js b/.yarn/sdks/typescript/lib/tsserverlibrary.js index 7f9d7f964..0e50e0a2b 100644 --- a/.yarn/sdks/typescript/lib/tsserverlibrary.js +++ b/.yarn/sdks/typescript/lib/tsserverlibrary.js @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); const absRequire = createRequire(absPnpApiPath); const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); @@ -23,7 +24,15 @@ if (existsSync(absPnpApiPath)) { } } -const moduleWrapper = tsserver => { +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + +const moduleWrapper = exports => { + return wrapWithUserWrapper(moduleWrapperFn(exports)); +}; + +const moduleWrapperFn = tsserver => { if (!process.versions.pnp) { return tsserver; } diff --git a/.yarn/sdks/typescript/lib/typescript.js b/.yarn/sdks/typescript/lib/typescript.js index 317b60b4c..7b6cc2207 100644 --- a/.yarn/sdks/typescript/lib/typescript.js +++ b/.yarn/sdks/typescript/lib/typescript.js @@ -8,6 +8,7 @@ const {pathToFileURL} = require(`url`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); const absRequire = createRequire(absPnpApiPath); const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); @@ -23,5 +24,9 @@ if (existsSync(absPnpApiPath)) { } } +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + // Defer to the real typescript your application uses -module.exports = absRequire(`typescript`); +module.exports = wrapWithUserWrapper(absRequire(`typescript`)); diff --git a/packages/allure-cucumberjs/src/reporter.ts b/packages/allure-cucumberjs/src/reporter.ts index f302e31ec..e6837eed3 100644 --- a/packages/allure-cucumberjs/src/reporter.ts +++ b/packages/allure-cucumberjs/src/reporter.ts @@ -8,7 +8,6 @@ import { type TestStepResult, TestStepResultStatus, } from "@cucumber/messages"; -import os from "node:os"; import { extname } from "node:path"; import process from "node:process"; import type { Label, Link, TestResult } from "allure-js-commons"; @@ -21,6 +20,8 @@ import { createDefaultWriter, createStepResult, getEnvironmentLabels, + getHostLabel, + getPackageLabelFromPath, getWorstStepResultStatus, md5, } from "allure-js-commons/sdk/reporter"; @@ -246,12 +247,11 @@ export default class AllureCucumberReporter extends Formatter { fullName, }; + const hostLabel = getHostLabel(); + const packageLabel = getPackageLabelFromPath(fullName); + result.labels!.push(...getEnvironmentLabels()); result.labels!.push( - { - name: LabelName.HOST, - value: os.hostname(), - }, { name: LabelName.LANGUAGE, value: "javascript", @@ -260,6 +260,8 @@ export default class AllureCucumberReporter extends Formatter { name: LabelName.FRAMEWORK, value: "cucumberjs", }, + packageLabel, + hostLabel, { name: LabelName.THREAD, value: data.workerId || ALLURE_THREAD_NAME || process.pid.toString(), diff --git a/packages/allure-cypress/src/reporter.ts b/packages/allure-cypress/src/reporter.ts index f01f231f7..554f74be7 100644 --- a/packages/allure-cypress/src/reporter.ts +++ b/packages/allure-cypress/src/reporter.ts @@ -6,7 +6,10 @@ import { ReporterRuntime, createDefaultWriter, getEnvironmentLabels, + getHostLabel, + getPackageLabelFromPath, getSuiteLabels, + getThreadLabel, parseTestPlan, } from "allure-js-commons/sdk/reporter"; import type { diff --git a/packages/allure-jasmine/src/index.ts b/packages/allure-jasmine/src/index.ts index 3ff8ba9e2..37193fd8f 100644 --- a/packages/allure-jasmine/src/index.ts +++ b/packages/allure-jasmine/src/index.ts @@ -1,5 +1,5 @@ import * as allure from "allure-js-commons"; -import { Stage, Status } from "allure-js-commons"; +import { LabelName, Stage, Status } from "allure-js-commons"; import type { RuntimeMessage } from "allure-js-commons/sdk"; import { getMessageAndTraceFromError, getStatusFromError, isPromise } from "allure-js-commons/sdk"; import type { FixtureType, ReporterConfig } from "allure-js-commons/sdk/reporter"; @@ -7,7 +7,10 @@ import { ReporterRuntime, createDefaultWriter, getEnvironmentLabels, + getHostLabel, + getPackageLabelFromPath, getSuiteLabels, + getThreadLabel, hasSkipLabel, } from "allure-js-commons/sdk/reporter"; import { MessageTestRuntime, setGlobalTestRuntime } from "allure-js-commons/sdk/runtime"; @@ -132,7 +135,7 @@ export default class AllureJasmineReporter implements jasmine.CustomReporter { } } - specDone(spec: jasmine.SpecResult): void { + specDone(spec: jasmine.SpecResult & { filename: string }): void { if (!this.currentAllureTestUuid) { return; } @@ -144,6 +147,11 @@ export default class AllureJasmineReporter implements jasmine.CustomReporter { result.labels.push(...suitesLabels); result.labels.push(...getEnvironmentLabels()); + result.labels.push({ name: LabelName.LANGUAGE, value: "javascript" }); + result.labels.push({ name: LabelName.FRAMEWORK, value: "jasmine" }); + result.labels.push(getHostLabel()); + result.labels.push(getPackageLabelFromPath(spec.filename)); + result.labels.push(getThreadLabel()); if (spec.status === "pending" || spec.status === "disabled" || spec.status === "excluded") { result.status = Status.SKIPPED; diff --git a/packages/allure-jasmine/test/spec/suites.test.ts b/packages/allure-jasmine/test/spec/suites.test.ts index f5aad3667..875e82c17 100644 --- a/packages/allure-jasmine/test/spec/suites.test.ts +++ b/packages/allure-jasmine/test/spec/suites.test.ts @@ -29,60 +29,49 @@ it("sets labels", async () => { `, }); - expect(tests).toHaveLength(3); - expect(tests).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - name: "should pass 1", - labels: [ - { - name: LabelName.PARENT_SUITE, - value: "first suite", - }, - { - name: LabelName.SUITE, - value: "second suite", - }, - { - name: LabelName.SUB_SUITE, - value: "third suite > fourth suite > fifth suite", - }, - ], - }), - expect.objectContaining({ - name: "should pass 2", - labels: [ - { - name: LabelName.PARENT_SUITE, - value: "first suite", - }, - { - name: LabelName.SUITE, - value: "second suite", - }, - { - name: LabelName.SUB_SUITE, - value: "third suite > fourth suite > fifth suite", - }, - ], - }), - expect.objectContaining({ - name: "should pass 3", - labels: [ - { - name: LabelName.PARENT_SUITE, - value: "first suite", - }, - { - name: LabelName.SUITE, - value: "second suite", - }, - { - name: LabelName.SUB_SUITE, - value: "third suite > fourth suite > fifth suite", - }, - ], - }), - ]), + const expectedValue = { + value: expect.any(String), + }; + + const testObject = [ + { + name: LabelName.LANGUAGE, + value: "javascript", + }, + { + name: LabelName.FRAMEWORK, + value: "jasmine", + }, + { + name: LabelName.HOST, + ...expectedValue, + }, + { + name: LabelName.PACKAGE, + ...expectedValue, + }, + { name: LabelName.THREAD, ...expectedValue }, + { + name: LabelName.PARENT_SUITE, + value: "first suite", + }, + { + name: LabelName.SUITE, + value: "second suite", + }, + { + name: LabelName.SUB_SUITE, + value: "third suite > fourth suite > fifth suite", + }, + ]; + + const testExpectations = tests.map(() => + expect.objectContaining({ + name: expect.any(String), + labels: expect.arrayContaining(testObject), + }), ); + + expect(tests).toHaveLength(3); + expect(tests).toEqual(expect.arrayContaining(testExpectations)); }); diff --git a/packages/allure-jest/src/environmentFactory.ts b/packages/allure-jest/src/environmentFactory.ts index f336f13ff..6a7dcd8a1 100644 --- a/packages/allure-jest/src/environmentFactory.ts +++ b/packages/allure-jest/src/environmentFactory.ts @@ -1,7 +1,7 @@ import type { EnvironmentContext, JestEnvironment, JestEnvironmentConfig } from "@jest/environment"; import type { Circus } from "@jest/types"; import os from "node:os"; -import { dirname, sep } from "node:path"; +import { sep } from "node:path"; import process from "node:process"; import * as allure from "allure-js-commons"; import { LabelName, Stage, Status } from "allure-js-commons"; @@ -191,7 +191,7 @@ const createJestEnvironment = (Base: T): T => const threadLabel = ALLURE_THREAD_NAME || JEST_WORKER_ID || process.pid.toString(); const hostLabel = ALLURE_HOST_NAME || hostname; - const packageLabel = dirname(this.testPath).split(sep).join("."); + const packageLabel = this.testPath.replace(sep, "."); this.#startScope(); const testUuid = this.runtime.startTest( diff --git a/packages/allure-playwright/src/index.ts b/packages/allure-playwright/src/index.ts index 169366cbc..bce721eed 100644 --- a/packages/allure-playwright/src/index.ts +++ b/packages/allure-playwright/src/index.ts @@ -177,7 +177,7 @@ export class AllureReporter implements ReporterV2 { fullName: `${relativeFile}:${test.location.line}:${test.location.column}`, }; - result.labels!.push({ name: LabelName.LANGUAGE, value: "JavaScript" }); + result.labels!.push({ name: LabelName.LANGUAGE, value: "javascript" }); result.labels!.push({ name: LabelName.FRAMEWORK, value: "Playwright" }); result.labels!.push({ name: "titlePath", value: suite.titlePath().join(" > ") }); result.labels!.push({ name: LabelName.PACKAGE, value: pathElements.join(".") }); diff --git a/packages/allure-playwright/test/spec/suites.spec.ts b/packages/allure-playwright/test/spec/suites.spec.ts index f7cf54099..6a9569346 100644 --- a/packages/allure-playwright/test/spec/suites.spec.ts +++ b/packages/allure-playwright/test/spec/suites.spec.ts @@ -37,7 +37,7 @@ it("reports a single suite structure", async () => { expect.arrayContaining([ { name: LabelName.LANGUAGE, - value: "JavaScript", + value: "javascript", }, { name: LabelName.FRAMEWORK, @@ -98,7 +98,7 @@ it("reports a multiple nested suites structure", async () => { expect.arrayContaining([ { name: LabelName.LANGUAGE, - value: "JavaScript", + value: "javascript", }, { name: LabelName.FRAMEWORK, diff --git a/packages/newman-reporter-allure/src/index.ts b/packages/newman-reporter-allure/src/index.ts index fc8c0e666..8980cf345 100644 --- a/packages/newman-reporter-allure/src/index.ts +++ b/packages/newman-reporter-allure/src/index.ts @@ -2,13 +2,17 @@ import type { EventEmitter } from "events"; import type { ConsoleEvent, Cursor, NewmanRunExecutionAssertion } from "newman"; import type { CollectionDefinition, Event, HeaderList, Item, Request, Response } from "postman-collection"; +import type { Label } from "allure-js-commons"; import { ContentType, LabelName, Stage, Status } from "allure-js-commons"; import type { ReporterConfig } from "allure-js-commons/sdk/reporter"; import { ReporterRuntime, createDefaultWriter, getEnvironmentLabels, + getHostLabel, + getPackageLabelFromPath, getSuiteLabels, + getThreadLabel, } from "allure-js-commons/sdk/reporter"; import type { PmItem, RunningItem } from "./model.js"; import { extractMeta } from "./utils.js"; @@ -74,9 +78,7 @@ class AllureReporter { return; } - const execScript = args.executions[0]?.script.exec?.join("\n"); - - currentPmItem.prerequest = execScript; + currentPmItem.prerequest = args.executions[0]?.script.exec?.join("\n"); } onBeforeItem(err: any, args: { item: Item; cursor: Cursor }) { @@ -91,7 +93,12 @@ class AllureReporter { const item = args.item; const fullName = this.#getFullName(item); const testPath = this.#pathToItem(item); + const hostLabel = getHostLabel(); + const threadLabel = getThreadLabel(); + const packageLabelFromPath: Label = getPackageLabelFromPath(""); + const { labels } = extractMeta(args.item.events); + this.currentTest = this.allureRuntime.startTest({ name: args.item.name, fullName, @@ -99,7 +106,10 @@ class AllureReporter { labels: [ { name: LabelName.LANGUAGE, value: "javascript" }, { name: LabelName.FRAMEWORK, value: "newman" }, - { name: LabelName.HOST, value: "localhost" }, + { name: LabelName.PACKAGE, value: "" }, + hostLabel, + threadLabel, + packageLabelFromPath, ...labels, ...getEnvironmentLabels(), ],