From 0a0651f0db310508e2e81c77b46b1cfbce81f839 Mon Sep 17 00:00:00 2001 From: epszaw Date: Tue, 1 Aug 2023 17:59:38 +0200 Subject: [PATCH] fix decorators by adding additional allure getter for mocha reporter --- packages/allure-decorators/test/fixtures/specs/baseTest.ts | 4 +++- packages/allure-mocha/runtime.d.ts | 2 +- packages/allure-mocha/runtime.js | 6 ++++++ packages/allure-mocha/src/MochaAllureReporter.ts | 6 +++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/allure-decorators/test/fixtures/specs/baseTest.ts b/packages/allure-decorators/test/fixtures/specs/baseTest.ts index d837c5f2c..07bd3f4f9 100644 --- a/packages/allure-decorators/test/fixtures/specs/baseTest.ts +++ b/packages/allure-decorators/test/fixtures/specs/baseTest.ts @@ -1,10 +1,12 @@ import { decorate } from "../../../"; -import { allure, MochaAllure } from "allure-mocha/runtime"; +import { allureGetter, MochaAllure } from "allure-mocha/runtime"; export class BaseTest { public static readonly TEST_URL = "https://custom.domain.com"; public before() { + const allure = allureGetter(); + decorate(allure); } } diff --git a/packages/allure-mocha/runtime.d.ts b/packages/allure-mocha/runtime.d.ts index 6fd11c565..bf394e6e2 100644 --- a/packages/allure-mocha/runtime.d.ts +++ b/packages/allure-mocha/runtime.d.ts @@ -1,3 +1,3 @@ export { MochaAllure } from "./dist/MochaAllure"; export { MochaAllureReporter } from "./dist/MochaAllureReporter"; -export { allure } from "./dist/MochaAllureReporter"; +export { allure, allureGetter } from "./dist/MochaAllureReporter"; diff --git a/packages/allure-mocha/runtime.js b/packages/allure-mocha/runtime.js index c028096e0..7ddbe8883 100644 --- a/packages/allure-mocha/runtime.js +++ b/packages/allure-mocha/runtime.js @@ -23,6 +23,12 @@ Object.defineProperty(module.exports, "allure", { return _MochaAllureReporter.allure; }, }); +Object.defineProperty(module.exports, "allureGetter", { + enumerable: true, + get: function () { + return _MochaAllureReporter.allureGetter; + }, +}); Object.defineProperty(module.exports, "MochaAllureReporter", { enumerable: true, get: function () { diff --git a/packages/allure-mocha/src/MochaAllureReporter.ts b/packages/allure-mocha/src/MochaAllureReporter.ts index cb10e2bac..1e1e92037 100644 --- a/packages/allure-mocha/src/MochaAllureReporter.ts +++ b/packages/allure-mocha/src/MochaAllureReporter.ts @@ -20,7 +20,11 @@ let mochaAllure: MochaAllure; // eslint-disable-next-line // @ts-ignore -export const allure: MochaAllure = new MochaAllureGateway(() => mochaAllure); +export const allure: MochaAllure = mochaAllure; + +// eslint-disable-next-line +// @ts-ignore +export const allureGetter: () => MochaAllure = () => mochaAllure; type ParallelRunner = Mocha.Runner & { linkPartialObjects?: (val: boolean) => ParallelRunner;