allure-jest 3.0.4 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -84
- package/package.json +13 -7
package/README.md
CHANGED
|
@@ -13,117 +13,113 @@
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
> **Warning**
|
|
16
|
-
> If you
|
|
17
|
-
>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
> This package only works with the [`jest-circus`](https://www.npmjs.com/package/jest-circus) test runner for Jest. It's the default runner for Jest starting from 27.0.0. If you use `jest@<27.0.0`, you should install `jest-circus` manually and set the [`testRunner`](https://jestjs.io/docs/configuration#testrunner-string) Jest option to `"jest-circus/runner"`.
|
|
17
|
+
> If you're a [`jest-jasmine2`](https://www.npmjs.com/package/jest-jasmine2) user, consider switching to `jest-circus`. If that's not an option for you, please use [allure-jasmine](https://allurereport.org/docs/jasmine/) instead.
|
|
18
|
+
|
|
19
|
+
## The documentation and examples
|
|
20
|
+
|
|
21
|
+
The docs for Allure Jest are available at [https://allurereport.org/docs/jest/](https://allurereport.org/docs/jest/).
|
|
22
|
+
|
|
23
|
+
Also, check out the examples at [github.com/allure-examples](https://github.com/orgs/allure-examples/repositories?q=visibility%3Apublic+archived%3Afalse+topic%3Aexample+topic%3Ajest).
|
|
21
24
|
|
|
22
25
|
## Installation
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
Install `allure-jest` using a package manager of your choice. For example:
|
|
25
28
|
|
|
26
29
|
```shell
|
|
27
|
-
npm
|
|
30
|
+
npm install -D allure-jest
|
|
28
31
|
```
|
|
29
32
|
|
|
30
|
-
If you're
|
|
33
|
+
> If you're a **Yarn PnP** user, you must also explicitly install the Jest environment package and `allure-js-commons`. For example:
|
|
34
|
+
> ```shell
|
|
35
|
+
> yarn add --dev jest-environment-node allure-js-commons
|
|
36
|
+
> ```
|
|
37
|
+
> Keep in mind, that `allure-js-commons` and `allure-jest` must have the same version. The same goes for all Jest packages (`jest`, `jest-circus`, `jest-environment-node`, etc). Use [`yarn info`](https://yarnpkg.com/cli/info) to check the versions.
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
/** @type {import('jest').Config} */
|
|
34
|
-
const config = {
|
|
35
|
-
+ testEnvironment: "allure-jest/node",
|
|
36
|
-
+ testEnvironmentOptions: {
|
|
37
|
-
+ resultsDir: "./allure-results"
|
|
38
|
-
+ }
|
|
39
|
-
}
|
|
39
|
+
## Usage
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
```
|
|
41
|
+
Set the [`testEnvironment`](https://jestjs.io/docs/configuration#testenvironment-string) Jest option according to your needs:
|
|
43
42
|
|
|
44
|
-
If you
|
|
43
|
+
- If you need access to DOM, set it to `"allure-jest/jsdom"` (make sure [jest-environment-jsdom](https://www.npmjs.com/package/jest-environment-jsdom) is installed).
|
|
44
|
+
- If you don't need access to DOM, set it to `"allure-jest/node"`.
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
Example:
|
|
47
|
+
|
|
48
|
+
```js
|
|
48
49
|
const config = {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
+ resultsDir: "./allure-results"
|
|
52
|
-
+ }
|
|
53
|
-
}
|
|
50
|
+
testEnvironment: "allure-jest/jsdom",
|
|
51
|
+
};
|
|
54
52
|
|
|
55
|
-
|
|
53
|
+
export default config;
|
|
56
54
|
```
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
When the test run completes, the result files will be generated in the `./allure-results` directory.
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
inside your tests:
|
|
58
|
+
You may select another location, or further customize the behavior of Allure Jest with [the configuration options](https://allurereport.org/docs/jest-configuration/).
|
|
62
59
|
|
|
63
|
-
|
|
64
|
-
import { attachment, epic, parameter } from "allure-js-commons";
|
|
60
|
+
### View the report
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
await attachment(currentTest.id(), screenshot, "image/png");
|
|
68
|
-
await epic(currentTest.id(), "my_epic");
|
|
69
|
-
await parameter(currentTest.id(), "parameter_name", "parameter_value", {
|
|
70
|
-
mode: "hidden",
|
|
71
|
-
excluded: false,
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Links usage
|
|
62
|
+
> You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it.
|
|
77
63
|
|
|
78
|
-
|
|
79
|
-
import { link, issue } from "allure-js-commons";
|
|
64
|
+
Generate Allure Report after the tests are executed:
|
|
80
65
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
await issue("Issue Name", "https://github.com/allure-framework/allure-js/issues/352");
|
|
84
|
-
});
|
|
66
|
+
```bash
|
|
67
|
+
allure generate ./allure-results -o ./allure-report
|
|
85
68
|
```
|
|
86
69
|
|
|
87
|
-
|
|
88
|
-
in `urlTemplate` parameter will be replaced by given value.
|
|
70
|
+
Open the generated report:
|
|
89
71
|
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
const config = {
|
|
93
|
-
testEnvironment: "allure-jest/node",
|
|
94
|
-
testEnvironmentOptions: {
|
|
95
|
-
resultsDir: "./allure-results",
|
|
96
|
-
+ links: [
|
|
97
|
-
+ {
|
|
98
|
-
+ type: "issue",
|
|
99
|
-
+ urlTemplate: "https://example.org/issues/%s",
|
|
100
|
-
+ nameTemplate: "Issue: %s",
|
|
101
|
-
+ },
|
|
102
|
-
+ {
|
|
103
|
-
+ type: "tms",
|
|
104
|
-
+ urlTemplate: "https://example.org/tasks/%s"
|
|
105
|
-
+ },
|
|
106
|
-
+ {
|
|
107
|
-
+ type: "custom",
|
|
108
|
-
+ urlTemplate: "https://example.org/custom/%s"
|
|
109
|
-
+ },
|
|
110
|
-
+ ]
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
module.exports = config
|
|
72
|
+
```bash
|
|
73
|
+
allure open ./allure-report
|
|
115
74
|
```
|
|
116
75
|
|
|
117
|
-
|
|
76
|
+
## Allure API
|
|
118
77
|
|
|
119
|
-
|
|
120
|
-
import { issue, tms, link } from "allure-js-commons";
|
|
78
|
+
Enhance the report by utilizing the runtime API:
|
|
121
79
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
80
|
+
```js
|
|
81
|
+
import * as allure from "allure-js-commons";
|
|
82
|
+
|
|
83
|
+
describe("signing in with a password", () => {
|
|
84
|
+
it("should sign in with a valid password", async () => {
|
|
85
|
+
await allure.description("The test checks if an active user with a valid password can sign in to the app.");
|
|
86
|
+
await allure.epic("Signing in");
|
|
87
|
+
await allure.feature("Sign in with a password");
|
|
88
|
+
await allure.story("As an active user, I want to successfully sign in using a valid password");
|
|
89
|
+
await allure.tags("signin", "ui", "positive");
|
|
90
|
+
await allure.issue("https://github.com/allure-framework/allure-js/issues/4", "ISSUE-4");
|
|
91
|
+
await allure.owner("eroshenkoam");
|
|
92
|
+
await allure.parameter("browser", "chrome");
|
|
93
|
+
|
|
94
|
+
const user = await allure.step("Prepare the user", async () => {
|
|
95
|
+
return await createAnActiveUserInDb();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
await allure.step("Make a sign-in attempt", async () => {
|
|
99
|
+
await allure.step("Navigate to the sign in page", async () => {
|
|
100
|
+
// ...
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
await allure.step("Fill the sign-in form", async (stepContext) => {
|
|
104
|
+
await stepContext.parameter("login", user.login);
|
|
105
|
+
await stepContext.parameter("password", user.password, "masked");
|
|
106
|
+
|
|
107
|
+
// ...
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
await allure.step("Submit the form", async () => {
|
|
111
|
+
// ...
|
|
112
|
+
// const responseData = ...
|
|
113
|
+
|
|
114
|
+
await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" });
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
await allure.step("Assert the signed-in state", async () => {
|
|
119
|
+
// ...
|
|
120
|
+
});
|
|
121
|
+
});
|
|
126
122
|
});
|
|
127
123
|
```
|
|
128
124
|
|
|
129
|
-
[
|
|
125
|
+
More details about the API are available at [https://allurereport.org/docs/jest-reference/](https://allurereport.org/docs/jest-reference/).
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "allure-jest",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"description": "Allure Jest integration",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"allure",
|
|
6
7
|
"jest",
|
|
7
8
|
"circus",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
9
|
+
"jasmine",
|
|
10
|
+
"html",
|
|
11
|
+
"test",
|
|
12
|
+
"report",
|
|
13
|
+
"reporter",
|
|
14
|
+
"testing",
|
|
15
|
+
"testops"
|
|
10
16
|
],
|
|
11
17
|
"homepage": "https://allurereport.org/",
|
|
12
18
|
"repository": {
|
|
@@ -26,7 +32,7 @@
|
|
|
26
32
|
"require": "./dist/cjs/node.js"
|
|
27
33
|
},
|
|
28
34
|
"./jsdom": {
|
|
29
|
-
"import": "./dist/esm/jsdom.
|
|
35
|
+
"import": "./dist/esm/jsdom.js",
|
|
30
36
|
"require": "./dist/cjs/jsdom.js"
|
|
31
37
|
}
|
|
32
38
|
},
|
|
@@ -47,7 +53,7 @@
|
|
|
47
53
|
"test": "vitest run"
|
|
48
54
|
},
|
|
49
55
|
"dependencies": {
|
|
50
|
-
"allure-js-commons": "3.0.
|
|
56
|
+
"allure-js-commons": "3.0.6"
|
|
51
57
|
},
|
|
52
58
|
"devDependencies": {
|
|
53
59
|
"@babel/cli": "^7.24.6",
|
|
@@ -65,7 +71,7 @@
|
|
|
65
71
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
66
72
|
"@typescript-eslint/parser": "^8.0.0",
|
|
67
73
|
"allure-commandline": "^2.29.0",
|
|
68
|
-
"allure-vitest": "3.0.
|
|
74
|
+
"allure-vitest": "3.0.6",
|
|
69
75
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
70
76
|
"eslint": "^8.57.0",
|
|
71
77
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -77,7 +83,7 @@
|
|
|
77
83
|
"jest-cli": "^29.7.0",
|
|
78
84
|
"jest-environment-jsdom": "^29.7.0",
|
|
79
85
|
"jest-environment-node": "^29.7.0",
|
|
80
|
-
"npm-run-all2": "^
|
|
86
|
+
"npm-run-all2": "^7.0.0",
|
|
81
87
|
"rimraf": "^6.0.0",
|
|
82
88
|
"typescript": "^5.2.2",
|
|
83
89
|
"vitest": "^1.6.0"
|