cypress-qase-reporter 2.0.3 → 2.1.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 +69 -21
- package/changelog.md +19 -0
- package/dist/child.d.ts +1 -1
- package/dist/child.js +7 -3
- package/dist/hooks.d.ts +1 -0
- package/dist/hooks.js +40 -0
- package/dist/mocha.d.ts +1 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/plugin.js +11 -0
- package/dist/reporter.d.ts +4 -2
- package/dist/reporter.js +12 -7
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -2,25 +2,71 @@
|
|
|
2
2
|
|
|
3
3
|
Publish results simple and easy.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
To install the latest release version (2.0.x), run:
|
|
6
8
|
|
|
7
9
|
```sh
|
|
8
10
|
npm install -D cypress-qase-reporter
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
You can update a test project from using version 1 to version 2 in several steps:
|
|
13
|
+
<!-- if there's no current beta, comment the next block
|
|
14
|
+
-->
|
|
14
15
|
|
|
15
|
-
1.
|
|
16
|
+
To install the latest beta version (2.1.x), run:
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
```
|
|
18
|
+
```sh
|
|
19
|
+
npm install -D cypress-qase-reporter@beta
|
|
20
|
+
```
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
## Updating from v1 to v2.1
|
|
23
|
+
|
|
24
|
+
To update an existing test project using Qase reporter from version 1 to version 2.1,
|
|
25
|
+
run the following steps:
|
|
26
|
+
|
|
27
|
+
1. Change import paths in your test files:
|
|
28
|
+
|
|
29
|
+
```diff
|
|
30
|
+
- import { qase } from 'cypress-qase-reporter/dist/mocha'
|
|
31
|
+
+ import { qase } from 'cypress-qase-reporter/mocha'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. Update reporter configuration in `cypress.config.js` and/or environment variables —
|
|
35
|
+
see the [configuration reference](#configuration) below.
|
|
36
|
+
|
|
37
|
+
3. Add a hook in the `e2e` section of `cypress.config.js`:
|
|
38
|
+
|
|
39
|
+
```diff
|
|
40
|
+
...
|
|
41
|
+
e2e: {
|
|
42
|
+
+ setupNodeEvents(on, config) {
|
|
43
|
+
+ require('cypress-qase-reporter/plugin')(on, config)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
...
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
If you already override `before:run` or `after:run` hooks in your `cypress.config.js`, use this instead:
|
|
50
|
+
|
|
51
|
+
```diff
|
|
52
|
+
const { beforeRunHook, afterRunHook } = require('cypress-qase-reporter/hooks');
|
|
53
|
+
|
|
54
|
+
...
|
|
55
|
+
e2e: {
|
|
56
|
+
setupNodeEvents(on, config) {
|
|
57
|
+
+ on('before:run', async () => {
|
|
58
|
+
+ console.log('override before:run');
|
|
59
|
+
+ await beforeRunHook(config);
|
|
60
|
+
+ });
|
|
61
|
+
|
|
62
|
+
+ on('after:run', async () => {
|
|
63
|
+
+ console.log('override after:run');
|
|
64
|
+
+ await afterRunHook(config);
|
|
65
|
+
+ });
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
...
|
|
69
|
+
```
|
|
24
70
|
|
|
25
71
|
## Getting started
|
|
26
72
|
|
|
@@ -41,20 +87,20 @@ import { qase } from 'cypress-qase-reporter/mocha';
|
|
|
41
87
|
|
|
42
88
|
describe('My First Test', () => {
|
|
43
89
|
qase(1,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
90
|
+
it('Several ids', () => {
|
|
91
|
+
expect(true).to.equal(true);
|
|
92
|
+
})
|
|
47
93
|
);
|
|
48
94
|
// a test can check multiple test cases
|
|
49
95
|
qase([2, 3],
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
96
|
+
it('Correct test', () => {
|
|
97
|
+
expect(true).to.equal(true);
|
|
98
|
+
})
|
|
53
99
|
);
|
|
54
100
|
qase(4,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
101
|
+
it.skip('Skipped test', () => {
|
|
102
|
+
expect(true).to.equal(true);
|
|
103
|
+
})
|
|
58
104
|
);
|
|
59
105
|
});
|
|
60
106
|
```
|
|
@@ -86,11 +132,13 @@ https://app.qase.io/run/QASE_PROJECT_CODE
|
|
|
86
132
|
## Configuration
|
|
87
133
|
|
|
88
134
|
Qase Cypress reporter can be configured in multiple ways:
|
|
135
|
+
|
|
89
136
|
- by adding configuration block in `cypress.config.js`,
|
|
90
137
|
- using a separate config file `qase.config.json`,
|
|
91
138
|
- using environment variables (they override the values from the configuration files).
|
|
92
139
|
|
|
93
|
-
For a full list of configuration options, see
|
|
140
|
+
For a full list of configuration options, see
|
|
141
|
+
the [Configuration reference](../qase-javascript-commons/README.md#configuration).
|
|
94
142
|
|
|
95
143
|
Example `cypress.config.js` config:
|
|
96
144
|
|
package/changelog.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# cypress-qase-reporter@2.1.0-beta.1
|
|
2
|
+
|
|
3
|
+
## What's new
|
|
4
|
+
|
|
5
|
+
- fixed an issue with the reporter completing the test run before all results are sent to Qase
|
|
6
|
+
- fixed an issue with the reporter not sending all results to Qase
|
|
7
|
+
|
|
8
|
+
Need to add the following to the `cypress.config.js` file:
|
|
9
|
+
|
|
10
|
+
```diff
|
|
11
|
+
...
|
|
12
|
+
e2e: {
|
|
13
|
+
setupNodeEvents(on, config) {
|
|
14
|
+
+ require('cypress-qase-reporter/plugin')(on, config);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
...
|
|
18
|
+
```
|
|
19
|
+
|
|
1
20
|
# cypress-qase-reporter@2.0.3
|
|
2
21
|
|
|
3
22
|
## What's new
|
package/dist/child.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/dist/child.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const qase_javascript_commons_1 = require("qase-javascript-commons");
|
|
4
|
+
const options = JSON.parse(process.env?.reporterConfig);
|
|
5
|
+
const results = JSON.parse(process.env?.results);
|
|
2
6
|
const runChild = async () => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
const reporter = qase_javascript_commons_1.QaseReporter.getInstance(options);
|
|
8
|
+
reporter.setTestResults(results);
|
|
9
|
+
await reporter.publish();
|
|
6
10
|
};
|
|
7
11
|
runChild();
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// <reference types="cypress" />
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const qase_javascript_commons_1 = require("qase-javascript-commons");
|
|
5
|
+
const configSchema_1 = require("./configSchema");
|
|
6
|
+
async function beforeRunHook(options) {
|
|
7
|
+
const configLoader = new qase_javascript_commons_1.ConfigLoader(configSchema_1.configSchema);
|
|
8
|
+
const config = configLoader.load();
|
|
9
|
+
const { reporterOptions } = options;
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11
|
+
const { ...composedOptions } = (0, qase_javascript_commons_1.composeOptions)(reporterOptions['cypressQaseReporterReporterOptions'], config);
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
13
|
+
const reporter = qase_javascript_commons_1.QaseReporter.getInstance({
|
|
14
|
+
...composedOptions,
|
|
15
|
+
frameworkPackage: 'cypress',
|
|
16
|
+
frameworkName: 'cypress',
|
|
17
|
+
reporterName: 'cypress-qase-reporter',
|
|
18
|
+
});
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
20
|
+
await reporter.startTestRunAsync();
|
|
21
|
+
}
|
|
22
|
+
async function afterRunHook(options) {
|
|
23
|
+
const configLoader = new qase_javascript_commons_1.ConfigLoader(configSchema_1.configSchema);
|
|
24
|
+
const config = configLoader.load();
|
|
25
|
+
const { reporterOptions } = options;
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
27
|
+
const { ...composedOptions } = (0, qase_javascript_commons_1.composeOptions)(reporterOptions['cypressQaseReporterReporterOptions'], config);
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
29
|
+
const reporter = qase_javascript_commons_1.QaseReporter.getInstance({
|
|
30
|
+
...composedOptions,
|
|
31
|
+
frameworkPackage: 'cypress',
|
|
32
|
+
frameworkName: 'cypress',
|
|
33
|
+
reporterName: 'cypress-qase-reporter',
|
|
34
|
+
});
|
|
35
|
+
await reporter.complete();
|
|
36
|
+
}
|
|
37
|
+
module.exports = {
|
|
38
|
+
beforeRunHook,
|
|
39
|
+
afterRunHook,
|
|
40
|
+
};
|
package/dist/mocha.d.ts
CHANGED
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const hooks_1 = require("./hooks");
|
|
4
|
+
module.exports = function (on, config) {
|
|
5
|
+
on('before:run', async () => {
|
|
6
|
+
await (0, hooks_1.beforeRunHook)(config);
|
|
7
|
+
});
|
|
8
|
+
on('after:run', async () => {
|
|
9
|
+
await (0, hooks_1.afterRunHook)(config);
|
|
10
|
+
});
|
|
11
|
+
};
|
package/dist/reporter.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
1
2
|
import { MochaOptions, reporters, Runner } from 'mocha';
|
|
2
|
-
import { ConfigLoader, TestStatusEnum } from 'qase-javascript-commons';
|
|
3
|
+
import { ConfigLoader, TestStatusEnum, FrameworkOptionsType } from 'qase-javascript-commons';
|
|
3
4
|
import { ReporterOptionsType } from './options';
|
|
4
5
|
type CypressState = 'failed' | 'passed' | 'pending';
|
|
5
6
|
export type CypressQaseOptionsType = Omit<MochaOptions, 'reporterOptions'> & {
|
|
@@ -41,12 +42,13 @@ export declare class CypressQaseReporter extends reporters.Base {
|
|
|
41
42
|
* @private
|
|
42
43
|
*/
|
|
43
44
|
private reporter;
|
|
45
|
+
private options;
|
|
44
46
|
/**
|
|
45
47
|
* @param {Runner} runner
|
|
46
48
|
* @param {CypressQaseOptionsType} options
|
|
47
49
|
* @param {ConfigLoaderInterface} configLoader
|
|
48
50
|
*/
|
|
49
|
-
constructor(runner: Runner, options: CypressQaseOptionsType, configLoader?: ConfigLoader<
|
|
51
|
+
constructor(runner: Runner, options: CypressQaseOptionsType, configLoader?: ConfigLoader<FrameworkOptionsType<"cypress", ReporterOptionsType>>);
|
|
50
52
|
/**
|
|
51
53
|
* @param {Runner} runner
|
|
52
54
|
* @private
|
package/dist/reporter.js
CHANGED
|
@@ -11,7 +11,7 @@ const mocha_1 = require("mocha");
|
|
|
11
11
|
const qase_javascript_commons_1 = require("qase-javascript-commons");
|
|
12
12
|
const traverse_dir_1 = require("./utils/traverse-dir");
|
|
13
13
|
const configSchema_1 = require("./configSchema");
|
|
14
|
-
const { EVENT_TEST_FAIL, EVENT_TEST_PASS, EVENT_TEST_PENDING, EVENT_RUN_END,
|
|
14
|
+
const { EVENT_TEST_FAIL, EVENT_TEST_PASS, EVENT_TEST_PENDING, EVENT_RUN_END, } = mocha_1.Runner.constants;
|
|
15
15
|
/**
|
|
16
16
|
* @class CypressQaseReporter
|
|
17
17
|
* @extends reporters.Base
|
|
@@ -63,6 +63,7 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
|
|
|
63
63
|
const config = configLoader.load();
|
|
64
64
|
const { framework, ...composedOptions } = (0, qase_javascript_commons_1.composeOptions)(reporterOptions, config);
|
|
65
65
|
this.screenshotsFolder = framework?.cypress?.screenshotsFolder;
|
|
66
|
+
this.options = composedOptions;
|
|
66
67
|
this.reporter = qase_javascript_commons_1.QaseReporter.getInstance({
|
|
67
68
|
...composedOptions,
|
|
68
69
|
frameworkPackage: 'cypress',
|
|
@@ -80,11 +81,15 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
|
|
|
80
81
|
runner.on(EVENT_TEST_PENDING, (test) => this.addTestResult(test));
|
|
81
82
|
runner.on(EVENT_TEST_FAIL, (test) => this.addTestResult(test));
|
|
82
83
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
83
|
-
runner.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
runner.once(EVENT_RUN_END, () => {
|
|
85
|
+
const results = this.reporter.getResults();
|
|
86
|
+
(0, child_process_1.spawnSync)('node', [`${__dirname}/child.js`], {
|
|
87
|
+
stdio: 'inherit',
|
|
88
|
+
env: Object.assign(process.env, {
|
|
89
|
+
reporterConfig: JSON.stringify(this.options),
|
|
90
|
+
results: JSON.stringify(results),
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
88
93
|
});
|
|
89
94
|
}
|
|
90
95
|
/**
|
|
@@ -122,7 +127,7 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
|
|
|
122
127
|
run_id: null,
|
|
123
128
|
signature: this.getSignature(test, ids),
|
|
124
129
|
steps: [],
|
|
125
|
-
id:
|
|
130
|
+
id: (0, uuid_1.v4)(),
|
|
126
131
|
execution: {
|
|
127
132
|
status: test.state
|
|
128
133
|
? CypressQaseReporter.statusMap[test.state]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cypress-qase-reporter",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.1.0-beta.2",
|
|
4
4
|
"description": "Qase Cypress Reporter",
|
|
5
5
|
"homepage": "https://github.com/qase-tms/qase-javascript",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
".": "./dist/index.js",
|
|
11
11
|
"./mocha": "./dist/mocha.js",
|
|
12
12
|
"./reporter": "./dist/reporter.js",
|
|
13
|
-
"./package.json": "./package.json"
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
"./plugin": "./dist/plugin.js",
|
|
15
|
+
"./hooks": "./dist/hooks.js"
|
|
14
16
|
},
|
|
15
17
|
"typesVersions": {
|
|
16
18
|
"*": {
|
|
@@ -44,7 +46,7 @@
|
|
|
44
46
|
"author": "Qase Team <support@qase.io>",
|
|
45
47
|
"license": "Apache-2.0",
|
|
46
48
|
"dependencies": {
|
|
47
|
-
"qase-javascript-commons": "
|
|
49
|
+
"qase-javascript-commons": "~2.1.0-beta.1",
|
|
48
50
|
"uuid": "^9.0.1"
|
|
49
51
|
},
|
|
50
52
|
"peerDependencies": {
|