Skip to content

Commit

Permalink
fix decorators by adding additional allure getter for mocha reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
epszaw committed Aug 1, 2023
1 parent 61be10f commit 0a0651f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/allure-decorators/test/fixtures/specs/baseTest.ts
Original file line number Diff line number Diff line change
@@ -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<MochaAllure>(allure);
}
}
2 changes: 1 addition & 1 deletion packages/allure-mocha/runtime.d.ts
Original file line number Diff line number Diff line change
@@ -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";
6 changes: 6 additions & 0 deletions packages/allure-mocha/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
6 changes: 5 additions & 1 deletion packages/allure-mocha/src/MochaAllureReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0a0651f

Please sign in to comment.