Skip to content

Commit

Permalink
feat(allure-jest): allow using allure with custom environments (fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
baev authored Jan 6, 2025
1 parent f0753df commit 52a3386
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
11 changes: 11 additions & 0 deletions packages/allure-jest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,14 @@ describe("signing in with a password", () => {
```
More details about the API are available at [https://allurereport.org/docs/jest-reference/](https://allurereport.org/docs/jest-reference/).
## Using Allure-Jest with custom environment
To use Allure-Jest with custom environments, you can use the `createJestEnvironment` helper function:
```js
import CustomTestEnvironment from "jest-environment-custom";
import { createJestEnvironment } from "allure-jest/factory";
export default createJestEnvironment(CustomTestEnvironment);
```
5 changes: 5 additions & 0 deletions packages/allure-jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"url": "https://qameta.io/"
},
"exports": {
"./factory": {
"types": "./dist/types/environmentFactory.d.ts",
"import": "./dist/esm/environmentFactory.js",
"require": "./dist/cjs/environmentFactory.js"
},
"./node": {
"types": "./dist/types/node.d.ts",
"import": "./dist/esm/node.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/allure-jest/src/environmentFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,4 @@ const createJestEnvironment = <T extends typeof JestEnvironment>(Base: T): T =>
};
};

export default createJestEnvironment;
export { createJestEnvironment };
2 changes: 1 addition & 1 deletion packages/allure-jest/src/jsdom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TestEnvironment from "jest-environment-jsdom";
import createJestEnvironment from "./environmentFactory.js";
import { createJestEnvironment } from "./environmentFactory.js";

export default createJestEnvironment(TestEnvironment);
2 changes: 1 addition & 1 deletion packages/allure-jest/src/node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TestEnvironment from "jest-environment-node";
import createJestEnvironment from "./environmentFactory.js";
import { createJestEnvironment } from "./environmentFactory.js";

export default createJestEnvironment(TestEnvironment);

0 comments on commit 52a3386

Please sign in to comment.