cypress-qase-reporter 2.0.0-beta.1 → 2.0.0-beta.2
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 +94 -69
- 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,64 @@
|
|
|
1
|
-
|
|
2
|
-
>
|
|
3
|
-
> Publish results simple and easy.
|
|
1
|
+
# Qase TMS Cypress reporter
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
Publish results simple and easy.
|
|
4
|
+
|
|
5
|
+
## How to install
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
npm install cypress-qase-reporter
|
|
8
|
+
npm install -D cypress-qase-reporter@beta
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Getting started
|
|
12
|
+
|
|
13
|
+
The Cypress reporter can auto-generate test cases
|
|
14
|
+
and suites from your test data.
|
|
15
|
+
Test results of subsequent test runs will match the same test cases
|
|
16
|
+
as long as their names and file paths don't change.
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
You can also annotate the tests with the IDs of existing test cases
|
|
19
|
+
from Qase.io before executing tests. It's a more reliable way to bind
|
|
20
|
+
autotests to test cases, that persists when you rename, move, or
|
|
21
|
+
parameterize your tests.
|
|
22
|
+
|
|
23
|
+
For example:
|
|
14
24
|
|
|
15
25
|
```typescript
|
|
16
|
-
import { qase } from 'cypress-qase-reporter';
|
|
26
|
+
import { qase } from 'cypress-qase-reporter/mocha';
|
|
17
27
|
|
|
18
28
|
describe('My First Test', () => {
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
qase(1,
|
|
30
|
+
it('Several ids', () => {
|
|
21
31
|
expect(true).to.equal(true);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
// a test can check multiple test cases
|
|
35
|
+
qase([2, 3],
|
|
36
|
+
it('Correct test', () => {
|
|
26
37
|
expect(true).to.equal(true);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
qase(4,
|
|
41
|
+
it.skip('Skipped test', () => {
|
|
31
42
|
expect(true).to.equal(true);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
qase(5,
|
|
35
|
-
it('Failed test', () => {
|
|
36
|
-
expect(true).to.equal(false);
|
|
37
|
-
})
|
|
38
|
-
);
|
|
43
|
+
})
|
|
44
|
+
);
|
|
39
45
|
});
|
|
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
46
|
```
|
|
54
47
|
|
|
55
|
-
To
|
|
48
|
+
To execute Cypress tests and report them to Qase.io, run the command:
|
|
49
|
+
|
|
56
50
|
```bash
|
|
57
51
|
QASE_MODE=testops npx cypress run
|
|
58
52
|
```
|
|
53
|
+
|
|
59
54
|
or
|
|
55
|
+
|
|
60
56
|
```bash
|
|
61
57
|
npm test
|
|
62
58
|
```
|
|
59
|
+
|
|
60
|
+
You can try it with the example project at [`examples/cypress`](../examples/cypress/).
|
|
61
|
+
|
|
63
62
|
<p align="center">
|
|
64
63
|
<img width="65%" src="./screenshots/screenshot.png">
|
|
65
64
|
</p>
|
|
@@ -72,39 +71,65 @@ https://app.qase.io/run/QASE_PROJECT_CODE
|
|
|
72
71
|
|
|
73
72
|
## Configuration
|
|
74
73
|
|
|
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
|
-
|
|
74
|
+
Qase Cypress reporter can be configured in multiple ways:
|
|
75
|
+
- by adding configuration block in `cypress.config.js`,
|
|
76
|
+
- using a separate config file `qase.config.json`,
|
|
77
|
+
- using environment variables (they override the values from the configuration files).
|
|
78
|
+
|
|
79
|
+
For a full list of configuration options, see the [Configuration reference](../qase-javascript-commons/README.md#configuration).
|
|
80
|
+
|
|
81
|
+
Example `cypress.config.js` config:
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
import cypress from 'cypress';
|
|
85
|
+
|
|
86
|
+
import plugins from './cypress/plugins/index.js';
|
|
87
|
+
|
|
88
|
+
module.exports = cypress.defineConfig({
|
|
89
|
+
reporter: 'cypress-multi-reporters',
|
|
90
|
+
reporterOptions: {
|
|
91
|
+
reporterEnabled: 'cypress-mochawesome-reporter, cypress-qase-reporter',
|
|
92
|
+
cypressMochawesomeReporterReporterOptions: {
|
|
93
|
+
charts: true,
|
|
94
|
+
},
|
|
95
|
+
cypressQaseReporterReporterOptions: {
|
|
96
|
+
debug: true,
|
|
97
|
+
|
|
98
|
+
testops: {
|
|
99
|
+
api: {
|
|
100
|
+
token: 'api_key',
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
project: 'project_code',
|
|
104
|
+
uploadAttachments: true,
|
|
105
|
+
|
|
106
|
+
run: {
|
|
107
|
+
complete: true,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
framework: {
|
|
112
|
+
cypress: {
|
|
113
|
+
screenshotsFolder: 'cypress/screenshots',
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
video: false,
|
|
119
|
+
e2e: {
|
|
120
|
+
setupNodeEvents(on, config) {
|
|
121
|
+
return plugins(on, config);
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Check out the example of configuration for multiple reporters in the
|
|
128
|
+
[demo project](../examples/cypress/cypress.config.js).
|
|
104
129
|
|
|
105
130
|
## Requirements
|
|
106
131
|
|
|
107
|
-
We maintain the reporter on LTS versions of Node
|
|
132
|
+
We maintain the reporter on [LTS versions of Node](https://nodejs.org/en/about/releases/).
|
|
108
133
|
|
|
109
134
|
`cypress >= 8.0.0`
|
|
110
135
|
|
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.2",
|
|
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.8",
|
|
48
|
+
"uuid": "^9.0.1"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"cypress": ">=8.0.0"
|