cypress-qase-reporter 2.0.0-beta.1 → 2.0.0-beta.3
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 +112 -70
- package/changelog.md +8 -0
- package/dist/reporter.d.ts +1 -1
- package/dist/reporter.js +37 -13
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,65 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
>
|
|
3
|
-
> Publish results simple and easy.
|
|
1
|
+
# Qase TMS Cypress reporter
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
Publish results simple and easy.
|
|
6
4
|
|
|
5
|
+
## How to install
|
|
6
|
+
|
|
7
|
+
Qase Cypress reporter is currently in open beta stage for the version 2 series.
|
|
8
|
+
To install the latest beta version, run:
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install -D cypress-qase-reporter@beta
|
|
7
12
|
```
|
|
8
|
-
npm install cypress-qase-reporter
|
|
9
|
-
```
|
|
10
13
|
|
|
11
|
-
##
|
|
14
|
+
## Updating from v1
|
|
15
|
+
|
|
16
|
+
You can update a test project from using version 1 to version 2 in several steps:
|
|
17
|
+
|
|
18
|
+
1. Change import paths:
|
|
19
|
+
|
|
20
|
+
```diff
|
|
21
|
+
- import { qase } from 'cypress-qase-reporter/dist/mocha'
|
|
22
|
+
+ import { qase } from 'cypress-qase-reporter/mocha'
|
|
23
|
+
```
|
|
12
24
|
|
|
13
|
-
|
|
25
|
+
2. Update reporter configuration in `cypress.config.js` and/or environment variables —
|
|
26
|
+
see the [configuration reference](#configuration) below.
|
|
27
|
+
|
|
28
|
+
## Getting started
|
|
29
|
+
|
|
30
|
+
The Cypress reporter can auto-generate test cases
|
|
31
|
+
and suites from your test data.
|
|
32
|
+
Test results of subsequent test runs will match the same test cases
|
|
33
|
+
as long as their names and file paths don't change.
|
|
34
|
+
|
|
35
|
+
You can also annotate the tests with the IDs of existing test cases
|
|
36
|
+
from Qase.io before executing tests. It's a more reliable way to bind
|
|
37
|
+
autotests to test cases, that persists when you rename, move, or
|
|
38
|
+
parameterize your tests.
|
|
39
|
+
|
|
40
|
+
For example:
|
|
14
41
|
|
|
15
42
|
```typescript
|
|
16
|
-
import { qase } from 'cypress-qase-reporter';
|
|
43
|
+
import { qase } from 'cypress-qase-reporter/mocha';
|
|
17
44
|
|
|
18
45
|
describe('My First Test', () => {
|
|
19
|
-
|
|
20
|
-
|
|
46
|
+
qase(1,
|
|
47
|
+
it('Several ids', () => {
|
|
21
48
|
expect(true).to.equal(true);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
// a test can check multiple test cases
|
|
52
|
+
qase([2, 3],
|
|
53
|
+
it('Correct test', () => {
|
|
26
54
|
expect(true).to.equal(true);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
qase(4,
|
|
58
|
+
it.skip('Skipped test', () => {
|
|
31
59
|
expect(true).to.equal(true);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
qase(5,
|
|
35
|
-
it('Failed test', () => {
|
|
36
|
-
expect(true).to.equal(false);
|
|
37
|
-
})
|
|
38
|
-
);
|
|
60
|
+
})
|
|
61
|
+
);
|
|
39
62
|
});
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
If you are going to use several specifications for execution and you have in config
|
|
43
|
-
```json
|
|
44
|
-
"testops": {
|
|
45
|
-
"run": {
|
|
46
|
-
"complete": true
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
then it is necessary to additionally set in the project settings
|
|
51
|
-
```
|
|
52
|
-
Allow to add results for cases in closed runs.
|
|
53
63
|
```
|
|
54
64
|
|
|
55
|
-
To
|
|
65
|
+
To execute Cypress tests and report them to Qase.io, run the command:
|
|
66
|
+
|
|
56
67
|
```bash
|
|
57
68
|
QASE_MODE=testops npx cypress run
|
|
58
69
|
```
|
|
70
|
+
|
|
59
71
|
or
|
|
72
|
+
|
|
60
73
|
```bash
|
|
61
74
|
npm test
|
|
62
75
|
```
|
|
76
|
+
|
|
77
|
+
You can try it with the example project at [`examples/cypress`](../examples/cypress/).
|
|
78
|
+
|
|
63
79
|
<p align="center">
|
|
64
80
|
<img width="65%" src="./screenshots/screenshot.png">
|
|
65
81
|
</p>
|
|
@@ -72,39 +88,65 @@ https://app.qase.io/run/QASE_PROJECT_CODE
|
|
|
72
88
|
|
|
73
89
|
## Configuration
|
|
74
90
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
91
|
+
Qase Cypress reporter can be configured in multiple ways:
|
|
92
|
+
- by adding configuration block in `cypress.config.js`,
|
|
93
|
+
- using a separate config file `qase.config.json`,
|
|
94
|
+
- using environment variables (they override the values from the configuration files).
|
|
95
|
+
|
|
96
|
+
For a full list of configuration options, see the [Configuration reference](../qase-javascript-commons/README.md#configuration).
|
|
97
|
+
|
|
98
|
+
Example `cypress.config.js` config:
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
import cypress from 'cypress';
|
|
102
|
+
|
|
103
|
+
import plugins from './cypress/plugins/index.js';
|
|
104
|
+
|
|
105
|
+
module.exports = cypress.defineConfig({
|
|
106
|
+
reporter: 'cypress-multi-reporters',
|
|
107
|
+
reporterOptions: {
|
|
108
|
+
reporterEnabled: 'cypress-mochawesome-reporter, cypress-qase-reporter',
|
|
109
|
+
cypressMochawesomeReporterReporterOptions: {
|
|
110
|
+
charts: true,
|
|
111
|
+
},
|
|
112
|
+
cypressQaseReporterReporterOptions: {
|
|
113
|
+
debug: true,
|
|
114
|
+
|
|
115
|
+
testops: {
|
|
116
|
+
api: {
|
|
117
|
+
token: 'api_key',
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
project: 'project_code',
|
|
121
|
+
uploadAttachments: true,
|
|
122
|
+
|
|
123
|
+
run: {
|
|
124
|
+
complete: true,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
framework: {
|
|
129
|
+
cypress: {
|
|
130
|
+
screenshotsFolder: 'cypress/screenshots',
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
video: false,
|
|
136
|
+
e2e: {
|
|
137
|
+
setupNodeEvents(on, config) {
|
|
138
|
+
return plugins(on, config);
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Check out the example of configuration for multiple reporters in the
|
|
145
|
+
[demo project](../examples/cypress/cypress.config.js).
|
|
104
146
|
|
|
105
147
|
## Requirements
|
|
106
148
|
|
|
107
|
-
We maintain the reporter on LTS versions of Node
|
|
149
|
+
We maintain the reporter on [LTS versions of Node](https://nodejs.org/en/about/releases/).
|
|
108
150
|
|
|
109
151
|
`cypress >= 8.0.0`
|
|
110
152
|
|
package/changelog.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# cypress-qase-reporter@2.0.0-beta.3
|
|
2
|
+
|
|
3
|
+
Fixed an issue with multiple test runs created when Cypress is running
|
|
4
|
+
multiple tests in parallel.
|
|
5
|
+
|
|
6
|
+
# cypress-qase-reporter@2.0.0-beta.2
|
|
7
|
+
|
|
8
|
+
First major beta release for the version 2 series of the Qase Cypress reporter.
|
package/dist/reporter.d.ts
CHANGED
package/dist/reporter.js
CHANGED
|
@@ -5,11 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CypressQaseReporter = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
8
9
|
const mocha_1 = require("mocha");
|
|
9
10
|
const qase_javascript_commons_1 = require("qase-javascript-commons");
|
|
10
11
|
const traverse_dir_1 = require("./utils/traverse-dir");
|
|
11
12
|
const configSchema_1 = require("./configSchema");
|
|
12
|
-
const { EVENT_TEST_FAIL, EVENT_TEST_PASS, EVENT_TEST_PENDING, EVENT_RUN_END, } = mocha_1.Runner.constants;
|
|
13
|
+
const { EVENT_TEST_FAIL, EVENT_TEST_PASS, EVENT_TEST_PENDING, EVENT_RUN_END, EVENT_RUN_BEGIN, } = mocha_1.Runner.constants;
|
|
13
14
|
/**
|
|
14
15
|
* @class CypressQaseReporter
|
|
15
16
|
* @extends reporters.Base
|
|
@@ -27,7 +28,7 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
|
|
|
27
28
|
/**
|
|
28
29
|
* @param {number[]} ids
|
|
29
30
|
* @param {string} dir
|
|
30
|
-
* @returns {
|
|
31
|
+
* @returns {Attachment[]}
|
|
31
32
|
* @private
|
|
32
33
|
*/
|
|
33
34
|
static findAttachments(ids, dir) {
|
|
@@ -36,11 +37,18 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
|
|
|
36
37
|
try {
|
|
37
38
|
(0, traverse_dir_1.traverseDir)(path_1.default.join(process.cwd(), dir), (filePath) => {
|
|
38
39
|
if (CypressQaseReporter.getCaseId(filePath).some((item) => idSet.has(item))) {
|
|
39
|
-
attachments.push(
|
|
40
|
+
attachments.push({
|
|
41
|
+
content: '',
|
|
42
|
+
id: (0, uuid_1.v4)(),
|
|
43
|
+
mime_type: '', size: 0,
|
|
44
|
+
file_name: path_1.default.basename(filePath),
|
|
45
|
+
file_path: filePath,
|
|
46
|
+
});
|
|
40
47
|
}
|
|
41
48
|
});
|
|
42
49
|
}
|
|
43
|
-
catch (error) { /* ignore */
|
|
50
|
+
catch (error) { /* ignore */
|
|
51
|
+
}
|
|
44
52
|
return attachments;
|
|
45
53
|
}
|
|
46
54
|
/**
|
|
@@ -71,6 +79,8 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
|
|
|
71
79
|
runner.on(EVENT_TEST_PENDING, (test) => this.addTestResult(test));
|
|
72
80
|
runner.on(EVENT_TEST_FAIL, (test) => this.addTestResult(test));
|
|
73
81
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
82
|
+
runner.on(EVENT_RUN_BEGIN, () => this.reporter.startTestRun());
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
74
84
|
runner.once(EVENT_RUN_END, async () => {
|
|
75
85
|
this.preventExit();
|
|
76
86
|
await this.reporter.publish();
|
|
@@ -89,18 +99,32 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
|
|
|
89
99
|
? CypressQaseReporter.findAttachments(ids, this.screenshotsFolder)
|
|
90
100
|
: undefined;
|
|
91
101
|
const result = {
|
|
102
|
+
attachments: attachments ?? [],
|
|
103
|
+
author: null,
|
|
104
|
+
fields: {},
|
|
105
|
+
message: test.err?.message ?? null,
|
|
106
|
+
muted: false,
|
|
107
|
+
params: {},
|
|
108
|
+
relations: {},
|
|
109
|
+
run_id: null,
|
|
110
|
+
signature: '',
|
|
111
|
+
steps: [],
|
|
92
112
|
id: test.id,
|
|
93
|
-
|
|
113
|
+
execution: {
|
|
114
|
+
status: test.state
|
|
115
|
+
? CypressQaseReporter.statusMap[test.state]
|
|
116
|
+
: qase_javascript_commons_1.TestStatusEnum.invalid,
|
|
117
|
+
start_time: null,
|
|
118
|
+
end_time: null,
|
|
119
|
+
duration: test.duration ?? 0,
|
|
120
|
+
stacktrace: test.err?.stack ?? null,
|
|
121
|
+
thread: null,
|
|
122
|
+
},
|
|
123
|
+
testops_id: ids.length > 0 ? ids : null,
|
|
94
124
|
title: test.title,
|
|
95
|
-
suiteTitle: test.parent?.titlePath(),
|
|
96
|
-
status: test.state
|
|
97
|
-
? CypressQaseReporter.statusMap[test.state]
|
|
98
|
-
: qase_javascript_commons_1.TestStatusEnum.invalid,
|
|
99
|
-
duration: test.duration ?? 0,
|
|
100
|
-
error: test.err,
|
|
101
|
-
attachments,
|
|
125
|
+
// suiteTitle: test.parent?.titlePath(),
|
|
102
126
|
};
|
|
103
|
-
this.reporter.addTestResult(result);
|
|
127
|
+
void this.reporter.addTestResult(result);
|
|
104
128
|
}
|
|
105
129
|
/**
|
|
106
130
|
* @private
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cypress-qase-reporter",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "Qase Cypress Reporter",
|
|
5
5
|
"homepage": "https://github.com/qase-tms/qase-javascript",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"author": "Nikita Fedorov <nik333r@gmail.com>",
|
|
45
45
|
"license": "Apache-2.0",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"qase-javascript-commons": "^2.0.0-beta.
|
|
47
|
+
"qase-javascript-commons": "^2.0.0-beta.9",
|
|
48
|
+
"uuid": "^9.0.1"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"cypress": ">=8.0.0"
|