cypress-qase-reporter 2.1.1 → 2.2.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 +34 -6
- package/changelog.md +47 -3
- package/dist/metadata/manager.d.ts +16 -0
- package/dist/metadata/manager.js +121 -0
- package/dist/metadata/models.d.ts +23 -0
- package/dist/metadata/models.js +2 -0
- package/dist/metadata.d.ts +1 -0
- package/dist/metadata.js +59 -0
- package/dist/mocha.d.ts +88 -1
- package/dist/mocha.js +118 -0
- package/dist/reporter.d.ts +1 -0
- package/dist/reporter.js +72 -6
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Publish results simple and easy.
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
To install the latest release version (2.
|
|
7
|
+
To install the latest release version (2.1.x), run:
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
10
|
npm install -D cypress-qase-reporter
|
|
@@ -13,7 +13,7 @@ npm install -D cypress-qase-reporter
|
|
|
13
13
|
<!-- if there's no current beta, comment the next block
|
|
14
14
|
-->
|
|
15
15
|
|
|
16
|
-
To install the latest beta version (2.
|
|
16
|
+
To install the latest beta version (2.2.x), run:
|
|
17
17
|
|
|
18
18
|
```sh
|
|
19
19
|
npm install -D cypress-qase-reporter@beta
|
|
@@ -30,7 +30,7 @@ run the following steps:
|
|
|
30
30
|
- import { qase } from 'cypress-qase-reporter/dist/mocha'
|
|
31
31
|
+ import { qase } from 'cypress-qase-reporter/mocha'
|
|
32
32
|
```
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
2. Update reporter configuration in `cypress.config.js` and/or environment variables —
|
|
35
35
|
see the [configuration reference](#configuration) below.
|
|
36
36
|
|
|
@@ -68,6 +68,23 @@ run the following steps:
|
|
|
68
68
|
...
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
+
## Updating from v2.1 to v2.2
|
|
72
|
+
|
|
73
|
+
To update an existing test project using Qase reporter from version 2.1 to version 2.2,
|
|
74
|
+
run the following steps:
|
|
75
|
+
|
|
76
|
+
1. Add a metadata in the `e2e` section of `cypress.config.js`
|
|
77
|
+
|
|
78
|
+
```diff
|
|
79
|
+
...
|
|
80
|
+
e2e: {
|
|
81
|
+
setupNodeEvents(on, config) {
|
|
82
|
+
require('cypress-qase-reporter/plugin')(on, config)
|
|
83
|
+
+ require('cypress-qase-reporter/metadata')(on)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
...
|
|
87
|
+
|
|
71
88
|
## Getting started
|
|
72
89
|
|
|
73
90
|
The Cypress reporter can auto-generate test cases
|
|
@@ -80,6 +97,17 @@ from Qase.io before executing tests. It's a more reliable way to bind
|
|
|
80
97
|
autotests to test cases, that persists when you rename, move, or
|
|
81
98
|
parameterize your tests.
|
|
82
99
|
|
|
100
|
+
### Metadata
|
|
101
|
+
|
|
102
|
+
- `qase.title` - set the title of the test case
|
|
103
|
+
- `qase.fields` - set the fields of the test case
|
|
104
|
+
- `qase.suite` - set the suite of the test case
|
|
105
|
+
- `qase.comment` - set the comment of the test case
|
|
106
|
+
- `qase.parameters` - set the parameters of the test case
|
|
107
|
+
- `qase.groupParameters` - set the group parameters of the test case
|
|
108
|
+
- `qase.ignore` - ignore the test case in Qase. The test will be executed, but the results will not be sent to Qase.
|
|
109
|
+
- `qase.step` - create a step in the test case
|
|
110
|
+
|
|
83
111
|
For example:
|
|
84
112
|
|
|
85
113
|
```typescript
|
|
@@ -88,6 +116,7 @@ import { qase } from 'cypress-qase-reporter/mocha';
|
|
|
88
116
|
describe('My First Test', () => {
|
|
89
117
|
qase(1,
|
|
90
118
|
it('Several ids', () => {
|
|
119
|
+
qase.title('My title');
|
|
91
120
|
expect(true).to.equal(true);
|
|
92
121
|
})
|
|
93
122
|
);
|
|
@@ -145,8 +174,6 @@ Example `cypress.config.js` config:
|
|
|
145
174
|
```js
|
|
146
175
|
import cypress from 'cypress';
|
|
147
176
|
|
|
148
|
-
import plugins from './cypress/plugins/index.js';
|
|
149
|
-
|
|
150
177
|
module.exports = cypress.defineConfig({
|
|
151
178
|
reporter: 'cypress-multi-reporters',
|
|
152
179
|
reporterOptions: {
|
|
@@ -180,7 +207,8 @@ module.exports = cypress.defineConfig({
|
|
|
180
207
|
video: false,
|
|
181
208
|
e2e: {
|
|
182
209
|
setupNodeEvents(on, config) {
|
|
183
|
-
|
|
210
|
+
require('cypress-qase-reporter/plugin')(on, config)
|
|
211
|
+
require('cypress-qase-reporter/metadata')(on)
|
|
184
212
|
},
|
|
185
213
|
},
|
|
186
214
|
});
|
package/changelog.md
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
# cypress-qase-reporter@2.2.0-beta.2
|
|
2
|
+
|
|
3
|
+
## What's new
|
|
4
|
+
|
|
5
|
+
Added the ability to add steps in tests:
|
|
6
|
+
|
|
7
|
+
- `qase.step` - add a step to the test
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
it('test', () => {
|
|
11
|
+
qase.step('Step 1', () => {
|
|
12
|
+
cy.visit('https://example.com');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
# cypress-qase-reporter@2.2.0-beta.1
|
|
18
|
+
|
|
19
|
+
## What's new
|
|
20
|
+
|
|
21
|
+
Added the ability to specify a test metadata in tests:
|
|
22
|
+
|
|
23
|
+
- `qase.title` - set the test title
|
|
24
|
+
- `qase.fields` - set the test fields
|
|
25
|
+
- `qase.suite` - set the test suite
|
|
26
|
+
- `qase.comment` - set the test comment
|
|
27
|
+
- `qase.parameters` - set the test parameters
|
|
28
|
+
- `qase.groupParameters` - set the test group parameters
|
|
29
|
+
- `qase.ignore` - ignore the test in Qase
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
it('test', () => {
|
|
33
|
+
qase.title('Title');
|
|
34
|
+
qase.fields({ field: 'value' });
|
|
35
|
+
qase.suite('Suite');
|
|
36
|
+
qase.comment('Comment');
|
|
37
|
+
qase.parameters({ param: 'value' });
|
|
38
|
+
qase.groupParameters({ param: 'value' });
|
|
39
|
+
qase.ignore();
|
|
40
|
+
|
|
41
|
+
cy.visit('https://example.com');
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
1
45
|
# cypress-qase-reporter@2.1.0
|
|
2
46
|
|
|
3
47
|
## What's new
|
|
@@ -40,8 +84,8 @@ The reporter will wait for all results to be sent to Qase and will not block the
|
|
|
40
84
|
|
|
41
85
|
## What's new
|
|
42
86
|
|
|
43
|
-
1. Cypress kills the process after the last tests.
|
|
44
|
-
The reporter will wait for all results to be sent to Qase and will not block the process after sending.
|
|
87
|
+
1. Cypress kills the process after the last tests.
|
|
88
|
+
The reporter will wait for all results to be sent to Qase and will not block the process after sending.
|
|
45
89
|
|
|
46
90
|
2. The reporter will collect suites and add them to results.
|
|
47
91
|
|
|
@@ -66,7 +110,7 @@ For more information about the new features and a guide for migration from v1, r
|
|
|
66
110
|
|
|
67
111
|
# cypress-qase-reporter@2.0.0-beta.3
|
|
68
112
|
|
|
69
|
-
Fixed an issue with multiple test runs created when Cypress is running
|
|
113
|
+
Fixed an issue with multiple test runs created when Cypress is running
|
|
70
114
|
multiple tests in parallel.
|
|
71
115
|
|
|
72
116
|
# cypress-qase-reporter@2.0.0-beta.2
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Metadata } from './models';
|
|
2
|
+
export declare class MetadataManager {
|
|
3
|
+
static getMetadata(): Metadata | undefined;
|
|
4
|
+
static setIgnore(): void;
|
|
5
|
+
static addStepStart(name: string): void;
|
|
6
|
+
static addStepEnd(status: string): void;
|
|
7
|
+
static setSuite(suite: string): void;
|
|
8
|
+
static setComment(comment: string): void;
|
|
9
|
+
static setTitle(title: string): void;
|
|
10
|
+
static setFields(fields: Record<string, string>): void;
|
|
11
|
+
static setParameters(parameters: Record<string, string>): void;
|
|
12
|
+
static setGroupParams(groupParams: Record<string, string>): void;
|
|
13
|
+
private static setMetadata;
|
|
14
|
+
static clear(): void;
|
|
15
|
+
static isExists(): boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetadataManager = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
const metadataPath = 'qaseMetadata';
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
8
|
+
class MetadataManager {
|
|
9
|
+
static getMetadata() {
|
|
10
|
+
if (!this.isExists()) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
let metadata = {
|
|
14
|
+
title: undefined,
|
|
15
|
+
fields: {},
|
|
16
|
+
parameters: {},
|
|
17
|
+
groupParams: {},
|
|
18
|
+
ignore: false,
|
|
19
|
+
suite: undefined,
|
|
20
|
+
comment: undefined,
|
|
21
|
+
steps: [],
|
|
22
|
+
currentStepId: undefined,
|
|
23
|
+
firstStepName: undefined,
|
|
24
|
+
};
|
|
25
|
+
try {
|
|
26
|
+
const data = (0, fs_1.readFileSync)(metadataPath, 'utf8');
|
|
27
|
+
metadata = JSON.parse(data);
|
|
28
|
+
return metadata;
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
console.error('Error reading metadata file:', err);
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
static setIgnore() {
|
|
36
|
+
const metadata = this.getMetadata() ?? {};
|
|
37
|
+
metadata.ignore = true;
|
|
38
|
+
this.setMetadata(metadata);
|
|
39
|
+
}
|
|
40
|
+
static addStepStart(name) {
|
|
41
|
+
const metadata = this.getMetadata() ?? {};
|
|
42
|
+
if (metadata.firstStepName === name) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (!metadata.steps) {
|
|
46
|
+
metadata.steps = [];
|
|
47
|
+
}
|
|
48
|
+
const id = (0, uuid_1.v4)();
|
|
49
|
+
const parentId = metadata.currentStepId ?? undefined;
|
|
50
|
+
metadata.steps.push({ timestamp: Date.now(), name, id: id, parentId: parentId });
|
|
51
|
+
metadata.currentStepId = id;
|
|
52
|
+
if (!metadata.firstStepName) {
|
|
53
|
+
metadata.firstStepName = name;
|
|
54
|
+
}
|
|
55
|
+
this.setMetadata(metadata);
|
|
56
|
+
}
|
|
57
|
+
static addStepEnd(status) {
|
|
58
|
+
const metadata = this.getMetadata() ?? {};
|
|
59
|
+
if (!metadata.steps || !metadata.currentStepId) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const parentId = metadata.steps.reverse().find((step) => step.id === metadata.currentStepId)?.parentId;
|
|
63
|
+
metadata.steps.push({ timestamp: Date.now(), status, id: metadata.currentStepId });
|
|
64
|
+
metadata.currentStepId = parentId;
|
|
65
|
+
this.setMetadata(metadata);
|
|
66
|
+
}
|
|
67
|
+
static setSuite(suite) {
|
|
68
|
+
const metadata = this.getMetadata() ?? {};
|
|
69
|
+
metadata.suite = suite;
|
|
70
|
+
this.setMetadata(metadata);
|
|
71
|
+
}
|
|
72
|
+
static setComment(comment) {
|
|
73
|
+
const metadata = this.getMetadata() ?? {};
|
|
74
|
+
metadata.comment = comment;
|
|
75
|
+
this.setMetadata(metadata);
|
|
76
|
+
}
|
|
77
|
+
static setTitle(title) {
|
|
78
|
+
const metadata = this.getMetadata() ?? {};
|
|
79
|
+
metadata.title = title;
|
|
80
|
+
this.setMetadata(metadata);
|
|
81
|
+
}
|
|
82
|
+
static setFields(fields) {
|
|
83
|
+
const metadata = this.getMetadata() ?? {};
|
|
84
|
+
metadata.fields = fields;
|
|
85
|
+
this.setMetadata(metadata);
|
|
86
|
+
}
|
|
87
|
+
static setParameters(parameters) {
|
|
88
|
+
const metadata = this.getMetadata() ?? {};
|
|
89
|
+
metadata.parameters = parameters;
|
|
90
|
+
this.setMetadata(metadata);
|
|
91
|
+
}
|
|
92
|
+
static setGroupParams(groupParams) {
|
|
93
|
+
const metadata = this.getMetadata() ?? {};
|
|
94
|
+
metadata.groupParams = groupParams;
|
|
95
|
+
this.setMetadata(metadata);
|
|
96
|
+
}
|
|
97
|
+
static setMetadata(metadata) {
|
|
98
|
+
try {
|
|
99
|
+
const data = JSON.stringify(metadata);
|
|
100
|
+
(0, fs_1.writeFileSync)(metadataPath, data);
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
console.error('Error writing metadata file:', err);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
static clear() {
|
|
107
|
+
if (!this.isExists()) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
(0, fs_1.unlinkSync)(metadataPath);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
console.error('Error clearing state file:', err);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
static isExists() {
|
|
118
|
+
return (0, fs_1.existsSync)(metadataPath);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.MetadataManager = MetadataManager;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface Metadata {
|
|
2
|
+
title?: string | undefined;
|
|
3
|
+
fields?: Record<string, string>;
|
|
4
|
+
parameters?: Record<string, string>;
|
|
5
|
+
groupParams?: Record<string, string>;
|
|
6
|
+
ignore?: boolean;
|
|
7
|
+
suite?: string | undefined;
|
|
8
|
+
comment?: string | undefined;
|
|
9
|
+
steps?: (StepStart | StepEnd)[];
|
|
10
|
+
currentStepId?: string | undefined;
|
|
11
|
+
firstStepName?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface StepStart {
|
|
14
|
+
id: string;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
name: string;
|
|
17
|
+
parentId: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface StepEnd {
|
|
20
|
+
id: string;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
status: string;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const manager_1 = require("./metadata/manager");
|
|
4
|
+
module.exports = function (on) {
|
|
5
|
+
on('task', {
|
|
6
|
+
qaseTitle(value) {
|
|
7
|
+
manager_1.MetadataManager.setTitle(value);
|
|
8
|
+
return null;
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
on('task', {
|
|
12
|
+
qaseFields(value) {
|
|
13
|
+
manager_1.MetadataManager.setFields(value);
|
|
14
|
+
return null;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
on('task', {
|
|
18
|
+
qaseIgnore() {
|
|
19
|
+
manager_1.MetadataManager.setIgnore();
|
|
20
|
+
return null;
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
on('task', {
|
|
24
|
+
qaseParameters(value) {
|
|
25
|
+
manager_1.MetadataManager.setParameters(value);
|
|
26
|
+
return null;
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
on('task', {
|
|
30
|
+
qaseGroupParameters(value) {
|
|
31
|
+
manager_1.MetadataManager.setGroupParams(value);
|
|
32
|
+
return null;
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
on('task', {
|
|
36
|
+
qaseSuite(value) {
|
|
37
|
+
manager_1.MetadataManager.setSuite(value);
|
|
38
|
+
return null;
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
on('task', {
|
|
42
|
+
qaseComment(value) {
|
|
43
|
+
manager_1.MetadataManager.setComment(value);
|
|
44
|
+
return null;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
on('task', {
|
|
48
|
+
qaseStepStart(value) {
|
|
49
|
+
manager_1.MetadataManager.addStepStart(value);
|
|
50
|
+
return null;
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
on('task', {
|
|
54
|
+
qaseStepEnd(value) {
|
|
55
|
+
manager_1.MetadataManager.addStepEnd(value);
|
|
56
|
+
return null;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
};
|
package/dist/mocha.d.ts
CHANGED
|
@@ -1,3 +1,90 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
|
+
/// <reference types="cypress" />
|
|
3
|
+
/// <reference types="cypress" />
|
|
4
|
+
/// <reference types="cypress" />
|
|
2
5
|
import { Test } from 'mocha';
|
|
3
|
-
export declare const qase:
|
|
6
|
+
export declare const qase: {
|
|
7
|
+
(caseId: number | string | number[] | string[], test: Test): Test;
|
|
8
|
+
/**
|
|
9
|
+
* Set a title for the test case
|
|
10
|
+
* @param {string} value
|
|
11
|
+
* @example
|
|
12
|
+
* it('test', () => {
|
|
13
|
+
* qase.title("Title");
|
|
14
|
+
* cy.visit('https://example.com');
|
|
15
|
+
* });
|
|
16
|
+
*/
|
|
17
|
+
title(value: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Set fields for the test case
|
|
20
|
+
* @param {Record<string, string>} values
|
|
21
|
+
* @example
|
|
22
|
+
* it('test', () => {
|
|
23
|
+
* qase.fields({description: "Description"});
|
|
24
|
+
* cy.visit('https://example.com');
|
|
25
|
+
* });
|
|
26
|
+
*/
|
|
27
|
+
fields(values: Record<string, string>): void;
|
|
28
|
+
/**
|
|
29
|
+
* Ignore the test case result in Qase
|
|
30
|
+
* @example
|
|
31
|
+
* it('test', () => {
|
|
32
|
+
* qase.ignore();
|
|
33
|
+
* cy.visit('https://example.com');
|
|
34
|
+
* });
|
|
35
|
+
*/
|
|
36
|
+
ignore(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Set parameters for the test case
|
|
39
|
+
* @param {Record<string, string>} values
|
|
40
|
+
* @example
|
|
41
|
+
* it('test', () => {
|
|
42
|
+
* qase.parameters({param01: "value01"});
|
|
43
|
+
* cy.visit('https://example.com');
|
|
44
|
+
* });
|
|
45
|
+
*/
|
|
46
|
+
parameters(values: Record<string, string>): void;
|
|
47
|
+
/**
|
|
48
|
+
* Set group parameters for the test case
|
|
49
|
+
* @param {Record<string, string>} values
|
|
50
|
+
* @example
|
|
51
|
+
* it('test', () => {
|
|
52
|
+
* qase.groupParameters({param01: "value01"});
|
|
53
|
+
* cy.visit('https://example.com');
|
|
54
|
+
* });
|
|
55
|
+
*/
|
|
56
|
+
groupParameters(values: Record<string, string>): void;
|
|
57
|
+
/**
|
|
58
|
+
* Set a suite for the test case
|
|
59
|
+
* @param {string} value
|
|
60
|
+
* @example
|
|
61
|
+
* it('test', () => {
|
|
62
|
+
* qase.suite("Suite 01");
|
|
63
|
+
* cy.visit('https://example.com');
|
|
64
|
+
* });
|
|
65
|
+
*/
|
|
66
|
+
suite(value: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Set a comment for the test case
|
|
69
|
+
* @param {string} value
|
|
70
|
+
* @example
|
|
71
|
+
* it('test', () => {
|
|
72
|
+
* qase.comment("Some comment");
|
|
73
|
+
* cy.visit('https://example.com');
|
|
74
|
+
* });
|
|
75
|
+
*/
|
|
76
|
+
comment(value: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* Add a step to the test case
|
|
79
|
+
* @param {string} name
|
|
80
|
+
* @param {() => T | PromiseLike<T>} body
|
|
81
|
+
* @example
|
|
82
|
+
* it('test', () => {
|
|
83
|
+
* qase.step("Some step", () => {
|
|
84
|
+
* // some actions
|
|
85
|
+
* });
|
|
86
|
+
* cy.visit('https://example.com');
|
|
87
|
+
* });
|
|
88
|
+
*/
|
|
89
|
+
step<T = void>(name: string, body: () => T | PromiseLike<T>): Cypress.Chainable<JQuery<void>>;
|
|
90
|
+
};
|
package/dist/mocha.js
CHANGED
|
@@ -7,3 +7,121 @@ const qase = (caseId, test) => {
|
|
|
7
7
|
return test;
|
|
8
8
|
};
|
|
9
9
|
exports.qase = qase;
|
|
10
|
+
/**
|
|
11
|
+
* Set a title for the test case
|
|
12
|
+
* @param {string} value
|
|
13
|
+
* @example
|
|
14
|
+
* it('test', () => {
|
|
15
|
+
* qase.title("Title");
|
|
16
|
+
* cy.visit('https://example.com');
|
|
17
|
+
* });
|
|
18
|
+
*/
|
|
19
|
+
exports.qase.title = (value) => {
|
|
20
|
+
cy.task('qaseTitle', value).then(() => {
|
|
21
|
+
//
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Set fields for the test case
|
|
26
|
+
* @param {Record<string, string>} values
|
|
27
|
+
* @example
|
|
28
|
+
* it('test', () => {
|
|
29
|
+
* qase.fields({description: "Description"});
|
|
30
|
+
* cy.visit('https://example.com');
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
33
|
+
exports.qase.fields = (values) => {
|
|
34
|
+
cy.task('qaseFields', values).then(() => {
|
|
35
|
+
//
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Ignore the test case result in Qase
|
|
40
|
+
* @example
|
|
41
|
+
* it('test', () => {
|
|
42
|
+
* qase.ignore();
|
|
43
|
+
* cy.visit('https://example.com');
|
|
44
|
+
* });
|
|
45
|
+
*/
|
|
46
|
+
exports.qase.ignore = () => {
|
|
47
|
+
cy.task('qaseIgnore').then(() => {
|
|
48
|
+
//
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Set parameters for the test case
|
|
53
|
+
* @param {Record<string, string>} values
|
|
54
|
+
* @example
|
|
55
|
+
* it('test', () => {
|
|
56
|
+
* qase.parameters({param01: "value01"});
|
|
57
|
+
* cy.visit('https://example.com');
|
|
58
|
+
* });
|
|
59
|
+
*/
|
|
60
|
+
exports.qase.parameters = (values) => {
|
|
61
|
+
cy.task('qaseParameters', values).then(() => {
|
|
62
|
+
//
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Set group parameters for the test case
|
|
67
|
+
* @param {Record<string, string>} values
|
|
68
|
+
* @example
|
|
69
|
+
* it('test', () => {
|
|
70
|
+
* qase.groupParameters({param01: "value01"});
|
|
71
|
+
* cy.visit('https://example.com');
|
|
72
|
+
* });
|
|
73
|
+
*/
|
|
74
|
+
exports.qase.groupParameters = (values) => {
|
|
75
|
+
cy.task('qaseGroupParameters', values).then(() => {
|
|
76
|
+
//
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Set a suite for the test case
|
|
81
|
+
* @param {string} value
|
|
82
|
+
* @example
|
|
83
|
+
* it('test', () => {
|
|
84
|
+
* qase.suite("Suite 01");
|
|
85
|
+
* cy.visit('https://example.com');
|
|
86
|
+
* });
|
|
87
|
+
*/
|
|
88
|
+
exports.qase.suite = (value) => {
|
|
89
|
+
cy.task('qaseSuite', value).then(() => {
|
|
90
|
+
//
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Set a comment for the test case
|
|
95
|
+
* @param {string} value
|
|
96
|
+
* @example
|
|
97
|
+
* it('test', () => {
|
|
98
|
+
* qase.comment("Some comment");
|
|
99
|
+
* cy.visit('https://example.com');
|
|
100
|
+
* });
|
|
101
|
+
*/
|
|
102
|
+
exports.qase.comment = (value) => {
|
|
103
|
+
cy.task('qaseComment', value).then(() => {
|
|
104
|
+
//
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Add a step to the test case
|
|
109
|
+
* @param {string} name
|
|
110
|
+
* @param {() => T | PromiseLike<T>} body
|
|
111
|
+
* @example
|
|
112
|
+
* it('test', () => {
|
|
113
|
+
* qase.step("Some step", () => {
|
|
114
|
+
* // some actions
|
|
115
|
+
* });
|
|
116
|
+
* cy.visit('https://example.com');
|
|
117
|
+
* });
|
|
118
|
+
*/
|
|
119
|
+
exports.qase.step = (name, body) => {
|
|
120
|
+
return cy.task('qaseStepStart', name).then(() => {
|
|
121
|
+
return Cypress.Promise.resolve(body());
|
|
122
|
+
}).then(() => {
|
|
123
|
+
cy.task('qaseStepEnd', 'passed').then(() => {
|
|
124
|
+
//
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
};
|
package/dist/reporter.d.ts
CHANGED
package/dist/reporter.js
CHANGED
|
@@ -11,6 +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 manager_1 = require("./metadata/manager");
|
|
14
15
|
const { EVENT_TEST_FAIL, EVENT_TEST_PASS, EVENT_TEST_PENDING, EVENT_RUN_END, } = mocha_1.Runner.constants;
|
|
15
16
|
/**
|
|
16
17
|
* @class CypressQaseReporter
|
|
@@ -97,6 +98,11 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
|
|
|
97
98
|
* @private
|
|
98
99
|
*/
|
|
99
100
|
addTestResult(test) {
|
|
101
|
+
const metadata = manager_1.MetadataManager.getMetadata();
|
|
102
|
+
if (metadata?.ignore) {
|
|
103
|
+
manager_1.MetadataManager.clear();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
100
106
|
const ids = CypressQaseReporter.getCaseId(test.title);
|
|
101
107
|
const attachments = this.screenshotsFolder
|
|
102
108
|
? CypressQaseReporter.findAttachments(ids, this.screenshotsFolder)
|
|
@@ -116,18 +122,40 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
|
|
|
116
122
|
},
|
|
117
123
|
};
|
|
118
124
|
}
|
|
125
|
+
if (metadata?.suite) {
|
|
126
|
+
relations = {
|
|
127
|
+
suite: {
|
|
128
|
+
data: [
|
|
129
|
+
{
|
|
130
|
+
title: metadata.suite,
|
|
131
|
+
public_id: null,
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
let message = null;
|
|
138
|
+
if (metadata?.comment) {
|
|
139
|
+
message = metadata.comment;
|
|
140
|
+
}
|
|
141
|
+
if (test.err?.message) {
|
|
142
|
+
if (message) {
|
|
143
|
+
message += '\n\n';
|
|
144
|
+
}
|
|
145
|
+
message += test.err.message;
|
|
146
|
+
}
|
|
119
147
|
const result = {
|
|
120
148
|
attachments: attachments ?? [],
|
|
121
149
|
author: null,
|
|
122
|
-
fields: {},
|
|
123
|
-
message:
|
|
150
|
+
fields: metadata?.fields ?? {},
|
|
151
|
+
message: message,
|
|
124
152
|
muted: false,
|
|
125
|
-
params: {},
|
|
126
|
-
group_params: {},
|
|
153
|
+
params: metadata?.parameters ?? {},
|
|
154
|
+
group_params: metadata?.groupParams ?? {},
|
|
127
155
|
relations: relations,
|
|
128
156
|
run_id: null,
|
|
129
157
|
signature: this.getSignature(test, ids),
|
|
130
|
-
steps: [],
|
|
158
|
+
steps: metadata?.steps ? this.getSteps(metadata.steps) : [],
|
|
131
159
|
id: (0, uuid_1.v4)(),
|
|
132
160
|
execution: {
|
|
133
161
|
status: test.state
|
|
@@ -140,9 +168,10 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
|
|
|
140
168
|
thread: null,
|
|
141
169
|
},
|
|
142
170
|
testops_id: ids.length > 0 ? ids : null,
|
|
143
|
-
title: test.title,
|
|
171
|
+
title: metadata?.title ?? test.title,
|
|
144
172
|
};
|
|
145
173
|
void this.reporter.addTestResult(result);
|
|
174
|
+
manager_1.MetadataManager.clear();
|
|
146
175
|
}
|
|
147
176
|
/**
|
|
148
177
|
* @param {Test} test
|
|
@@ -179,6 +208,43 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
|
|
|
179
208
|
}
|
|
180
209
|
return undefined;
|
|
181
210
|
}
|
|
211
|
+
getSteps(steps) {
|
|
212
|
+
const result = [];
|
|
213
|
+
const stepMap = new Map();
|
|
214
|
+
for (const step of steps.sort((a, b) => a.timestamp - b.timestamp)) {
|
|
215
|
+
if (!('status' in step)) {
|
|
216
|
+
const newStep = new qase_javascript_commons_1.TestStepType();
|
|
217
|
+
newStep.id = step.id;
|
|
218
|
+
newStep.execution.status = qase_javascript_commons_1.StepStatusEnum.failed;
|
|
219
|
+
newStep.execution.start_time = step.timestamp;
|
|
220
|
+
newStep.execution.end_time = Date.now();
|
|
221
|
+
newStep.data = {
|
|
222
|
+
action: step.name,
|
|
223
|
+
expected_result: null,
|
|
224
|
+
};
|
|
225
|
+
const parentId = step.parentId;
|
|
226
|
+
if (parentId) {
|
|
227
|
+
newStep.parent_id = parentId;
|
|
228
|
+
const parent = stepMap.get(parentId);
|
|
229
|
+
if (parent) {
|
|
230
|
+
parent.steps.push(newStep);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
result.push(newStep);
|
|
235
|
+
}
|
|
236
|
+
stepMap.set(step.id, newStep);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
const stepType = stepMap.get(step.id);
|
|
240
|
+
if (stepType) {
|
|
241
|
+
stepType.execution.status = step.status;
|
|
242
|
+
stepType.execution.end_time = step.timestamp;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return result;
|
|
247
|
+
}
|
|
182
248
|
}
|
|
183
249
|
exports.CypressQaseReporter = CypressQaseReporter;
|
|
184
250
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cypress-qase-reporter",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-beta.2",
|
|
4
4
|
"description": "Qase Cypress Reporter",
|
|
5
5
|
"homepage": "https://github.com/qase-tms/qase-javascript",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"./reporter": "./dist/reporter.js",
|
|
13
13
|
"./package.json": "./package.json",
|
|
14
14
|
"./plugin": "./dist/plugin.js",
|
|
15
|
+
"./metadata": "./dist/metadata.js",
|
|
15
16
|
"./hooks": "./dist/hooks.js"
|
|
16
17
|
},
|
|
17
18
|
"typesVersions": {
|