Skip to content

Commit

Permalink
update docs for jest and jasmine
Browse files Browse the repository at this point in the history
  • Loading branch information
epszaw committed Aug 17, 2023
1 parent 3ae8dba commit 3edab11
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
42 changes: 42 additions & 0 deletions packages/allure-jasmine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,45 @@
Allure integration Jasmine framework

For usage example see `test/Setup.ts`

## Usage with Jest (`jest@<27`)

> If you're looking for `jest-circus` integration (`[email protected]`) you need to
> use [`allure-jest` package][allure-jest] instead.
Use your favorite node package manager to install required packages:

```bash
npm i -D jest-jasmine2 allure-jasmine allure-js-commons @types/jasmine
```

Create `allure-setup.ts` file:

```ts
import { JasmineAllureReporter } from "allure-jasmine";
import { JasmineAllureInterface } from "allure-jasmine/dist/src/JasmineAllureReporter";

const reporter = new JasmineAllureReporter({ resultsDir: "allure-results" });

jasmine.getEnv().addReporter(reporter);
// @ts-expect-error
global.allure = reporter.getInterface();

declare global {
const allure: JasmineAllureInterface;
}
```

Change your `jest.config.js` file:

```js
module.exports = {
preset: "ts-jest",
+ testRunner: "jest-jasmine2",
+ setupFilesAfterEnv: ["./allure-setup.ts"],
};
```

You can find example setup and usage in this [repo](https://github.com/vovsemenv/allure-jest-example)

[allure-jest]: https://github.com/allure-framework/allure-js/tree/master/packages/allure-jest
4 changes: 3 additions & 1 deletion packages/allure-jest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Allure integration for `jest@^27.x.x` (`jest-circus`).

> **Warning**
> If you're looking for `jest-jasmine` integration (`< 27.x.x`) you need to
> change default runner to `Jasmine` and use `allure-jasmine` instead.
> change default runner to `Jasmine` and use [`allure-jasmine` package][allure-jasmine] instead.
## Installation

Expand Down Expand Up @@ -41,3 +41,5 @@ it("my test", () => {
});
});
```

[allure-jasmine]: https://github.com/allure-framework/allure-js/tree/master/packages/allure-jasmine

0 comments on commit 3edab11

Please sign in to comment.