testcafe-reporter-qase 2.0.0 → 2.0.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/changelog.md +22 -0
- package/dist/factory.d.ts +1 -1
- package/dist/factory.js +6 -2
- package/dist/qase.d.ts +13 -0
- package/dist/qase.js +17 -0
- package/dist/reporter.d.ts +12 -8
- package/dist/reporter.js +43 -21
- package/package.json +2 -2
package/changelog.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
# qase-testcafe@2.0.2
|
|
2
|
+
|
|
3
|
+
## What's new
|
|
4
|
+
|
|
5
|
+
Improved error collection. The error stack trace contains more useful debugging information: browser, code, etc.
|
|
6
|
+
|
|
7
|
+
# qase-testcafe@2.0.1
|
|
8
|
+
|
|
9
|
+
## What's new
|
|
10
|
+
|
|
11
|
+
Support group parameters for test cases. You can specify the group parameters in the test case using the following format:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
const q = qase.groupParameters({ 'param01': 'value01', 'param02': 'value02' }).create();
|
|
15
|
+
test.meta({ ...q })(
|
|
16
|
+
'test',
|
|
17
|
+
async (t) => {
|
|
18
|
+
await t;
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
```
|
|
22
|
+
|
|
1
23
|
# qase-testcafe@2.0.0
|
|
2
24
|
|
|
3
25
|
## What's new
|
package/dist/factory.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export declare const factory: (options: TestcafeQaseOptionsType) => {
|
|
|
7
7
|
noColors: boolean;
|
|
8
8
|
reportTaskStart: () => void;
|
|
9
9
|
reportFixtureStart: () => void;
|
|
10
|
-
reportTestDone
|
|
10
|
+
reportTestDone(name: string, testRunInfo: TestRunInfoType, meta: Record<string, string>): Promise<void>;
|
|
11
11
|
reportTaskDone: () => Promise<void>;
|
|
12
12
|
};
|
package/dist/factory.js
CHANGED
|
@@ -16,8 +16,12 @@ const factory = (options) => {
|
|
|
16
16
|
reportFixtureStart: () => {
|
|
17
17
|
/* empty */
|
|
18
18
|
},
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
async reportTestDone(name, testRunInfo, meta) {
|
|
20
|
+
return reporter.reportTestDone(name, testRunInfo, meta,
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
22
|
+
// @ts-expect-error Inject testrail error formatting method with bound context
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument
|
|
24
|
+
this.formatError.bind(this));
|
|
21
25
|
},
|
|
22
26
|
reportTaskDone: async () => {
|
|
23
27
|
await reporter.reportTaskDone();
|
package/dist/qase.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare class qase {
|
|
|
3
3
|
private static _qaseTitle;
|
|
4
4
|
private static _qaseFields;
|
|
5
5
|
private static _qaseParameters;
|
|
6
|
+
private static _qaseGroupParameters;
|
|
6
7
|
/**
|
|
7
8
|
* Set a Qase ID for the test case
|
|
8
9
|
* Don't forget to call `create` method after setting all the necessary parameters
|
|
@@ -47,6 +48,17 @@ export declare class qase {
|
|
|
47
48
|
* test.meta({userField: 123, ...q})('Test case title', async t => { ... });
|
|
48
49
|
*/
|
|
49
50
|
static parameters: (values: Record<string, string>) => typeof qase;
|
|
51
|
+
/**
|
|
52
|
+
* Set a group parameters for the test case
|
|
53
|
+
* Don't forget to call `create` method after setting all the necessary parameters
|
|
54
|
+
* @param {Record<string, string>} values
|
|
55
|
+
* @example
|
|
56
|
+
* const q = qase.group_parameters({ 'severity': 'high', 'priority': 'medium' }).create();
|
|
57
|
+
* test.meta(q)('Test case title', async t => { ... });
|
|
58
|
+
* or
|
|
59
|
+
* test.meta({userField: 123, ...q})('Test case title', async t => { ... });
|
|
60
|
+
*/
|
|
61
|
+
static group_parameters: (values: Record<string, string>) => typeof qase;
|
|
50
62
|
/**
|
|
51
63
|
* Create a Qase metadata
|
|
52
64
|
* Call this method after setting all the necessary parameters
|
|
@@ -61,6 +73,7 @@ export declare class qase {
|
|
|
61
73
|
QaseTitle: string;
|
|
62
74
|
QaseFields: string;
|
|
63
75
|
QaseParameters: string;
|
|
76
|
+
QaseGroupParameters: string;
|
|
64
77
|
};
|
|
65
78
|
private static toNormalizeRecord;
|
|
66
79
|
}
|
package/dist/qase.js
CHANGED
|
@@ -11,6 +11,7 @@ qase._qaseID = '';
|
|
|
11
11
|
qase._qaseTitle = '';
|
|
12
12
|
qase._qaseFields = '';
|
|
13
13
|
qase._qaseParameters = '';
|
|
14
|
+
qase._qaseGroupParameters = '';
|
|
14
15
|
/**
|
|
15
16
|
* Set a Qase ID for the test case
|
|
16
17
|
* Don't forget to call `create` method after setting all the necessary parameters
|
|
@@ -67,6 +68,20 @@ qase.parameters = (values) => {
|
|
|
67
68
|
_a._qaseParameters = _a.toNormalizeRecord(values);
|
|
68
69
|
return _a;
|
|
69
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Set a group parameters for the test case
|
|
73
|
+
* Don't forget to call `create` method after setting all the necessary parameters
|
|
74
|
+
* @param {Record<string, string>} values
|
|
75
|
+
* @example
|
|
76
|
+
* const q = qase.group_parameters({ 'severity': 'high', 'priority': 'medium' }).create();
|
|
77
|
+
* test.meta(q)('Test case title', async t => { ... });
|
|
78
|
+
* or
|
|
79
|
+
* test.meta({userField: 123, ...q})('Test case title', async t => { ... });
|
|
80
|
+
*/
|
|
81
|
+
qase.group_parameters = (values) => {
|
|
82
|
+
_a._qaseGroupParameters = _a.toNormalizeRecord(values);
|
|
83
|
+
return _a;
|
|
84
|
+
};
|
|
70
85
|
/**
|
|
71
86
|
* Create a Qase metadata
|
|
72
87
|
* Call this method after setting all the necessary parameters
|
|
@@ -82,11 +97,13 @@ qase.create = () => {
|
|
|
82
97
|
QaseTitle: _a._qaseTitle,
|
|
83
98
|
QaseFields: _a._qaseFields,
|
|
84
99
|
QaseParameters: _a._qaseParameters,
|
|
100
|
+
QaseGroupParameters: _a._qaseGroupParameters,
|
|
85
101
|
};
|
|
86
102
|
_a._qaseID = '';
|
|
87
103
|
_a._qaseTitle = '';
|
|
88
104
|
_a._qaseFields = '';
|
|
89
105
|
_a._qaseParameters = '';
|
|
106
|
+
_a._qaseGroupParameters = '';
|
|
90
107
|
return meta;
|
|
91
108
|
};
|
|
92
109
|
qase.toNormalizeRecord = (record) => {
|
package/dist/reporter.d.ts
CHANGED
|
@@ -11,10 +11,11 @@ interface TestRunErrorFormattableAdapterType {
|
|
|
11
11
|
screenshotPath: string;
|
|
12
12
|
testRunId: string;
|
|
13
13
|
testRunPhase: string;
|
|
14
|
+
type: string;
|
|
14
15
|
code?: string;
|
|
15
16
|
isTestCafeError?: boolean;
|
|
16
17
|
callsite?: CallsiteRecordType;
|
|
17
|
-
errMsg
|
|
18
|
+
errMsg: string;
|
|
18
19
|
diff?: boolean;
|
|
19
20
|
id?: string;
|
|
20
21
|
}
|
|
@@ -53,12 +54,6 @@ export declare class TestcafeQaseReporter {
|
|
|
53
54
|
* @private
|
|
54
55
|
*/
|
|
55
56
|
private static getStatus;
|
|
56
|
-
/**
|
|
57
|
-
* @param {TestRunErrorFormattableAdapterType[]} errors
|
|
58
|
-
* @returns {Error}
|
|
59
|
-
* @private
|
|
60
|
-
*/
|
|
61
|
-
private static transformErrors;
|
|
62
57
|
/**
|
|
63
58
|
* @param {ScreenshotType[]} screenshots
|
|
64
59
|
* @returns {Attachment[]}
|
|
@@ -83,12 +78,21 @@ export declare class TestcafeQaseReporter {
|
|
|
83
78
|
* @param {string} title
|
|
84
79
|
* @param {TestRunInfoType} testRunInfo
|
|
85
80
|
* @param {Record<string, string>} meta
|
|
81
|
+
* @param formatError
|
|
86
82
|
*/
|
|
87
|
-
reportTestDone: (title: string, testRunInfo: TestRunInfoType, meta: Record<string, string
|
|
83
|
+
reportTestDone: (title: string, testRunInfo: TestRunInfoType, meta: Record<string, string>, formatError: (error: any, prefix: string) => string) => Promise<void>;
|
|
88
84
|
/**
|
|
89
85
|
* @returns {Promise<void>}
|
|
90
86
|
*/
|
|
91
87
|
reportTaskDone: () => Promise<void>;
|
|
92
88
|
private getMeta;
|
|
89
|
+
/**
|
|
90
|
+
* @param {FixtureType} fixture
|
|
91
|
+
* @param {string} title
|
|
92
|
+
* @param {number[]} ids
|
|
93
|
+
* @param {Record<string, string>} parameters
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
private getSignature;
|
|
93
97
|
}
|
|
94
98
|
export {};
|
package/dist/reporter.js
CHANGED
|
@@ -9,6 +9,7 @@ var metadataEnum;
|
|
|
9
9
|
metadataEnum["title"] = "QaseTitle";
|
|
10
10
|
metadataEnum["fields"] = "QaseFields";
|
|
11
11
|
metadataEnum["parameters"] = "QaseParameters";
|
|
12
|
+
metadataEnum["groupParameters"] = "QaseGroupParameters";
|
|
12
13
|
metadataEnum["oldID"] = "CID";
|
|
13
14
|
})(metadataEnum || (metadataEnum = {}));
|
|
14
15
|
/**
|
|
@@ -29,22 +30,6 @@ class TestcafeQaseReporter {
|
|
|
29
30
|
}
|
|
30
31
|
return qase_javascript_commons_1.TestStatusEnum.passed;
|
|
31
32
|
}
|
|
32
|
-
/**
|
|
33
|
-
* @param {TestRunErrorFormattableAdapterType[]} errors
|
|
34
|
-
* @returns {Error}
|
|
35
|
-
* @private
|
|
36
|
-
*/
|
|
37
|
-
static transformErrors(errors) {
|
|
38
|
-
const [errorMessages, errorStacks] = errors.reduce(([messages, stacks], error) => {
|
|
39
|
-
const stack = error.callsite?.stackFrames?.map((line) => String(line)) ?? [];
|
|
40
|
-
messages.push(error.errMsg ?? 'Error');
|
|
41
|
-
stacks.push(stack.join('\n'));
|
|
42
|
-
return [messages, stacks];
|
|
43
|
-
}, [[], []]);
|
|
44
|
-
const error = new Error(errorMessages.join('\n\n'));
|
|
45
|
-
error.stack = errorStacks.join('\n\n');
|
|
46
|
-
return error;
|
|
47
|
-
}
|
|
48
33
|
/**
|
|
49
34
|
* @param {ScreenshotType[]} screenshots
|
|
50
35
|
* @returns {Attachment[]}
|
|
@@ -79,9 +64,14 @@ class TestcafeQaseReporter {
|
|
|
79
64
|
* @param {string} title
|
|
80
65
|
* @param {TestRunInfoType} testRunInfo
|
|
81
66
|
* @param {Record<string, string>} meta
|
|
67
|
+
* @param formatError
|
|
82
68
|
*/
|
|
83
|
-
this.reportTestDone = async (title, testRunInfo, meta) => {
|
|
84
|
-
const
|
|
69
|
+
this.reportTestDone = async (title, testRunInfo, meta, formatError) => {
|
|
70
|
+
const errorLog = testRunInfo.errs
|
|
71
|
+
.map((error, index) => formatError(error, `${index + 1} `).replace(
|
|
72
|
+
// eslint-disable-next-line no-control-regex
|
|
73
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ''))
|
|
74
|
+
.join('\n');
|
|
85
75
|
const metadata = this.getMeta(meta);
|
|
86
76
|
await this.reporter.addTestResult({
|
|
87
77
|
author: null,
|
|
@@ -90,13 +80,14 @@ class TestcafeQaseReporter {
|
|
|
90
80
|
start_time: null,
|
|
91
81
|
end_time: null,
|
|
92
82
|
duration: testRunInfo.durationMs,
|
|
93
|
-
stacktrace:
|
|
83
|
+
stacktrace: errorLog,
|
|
94
84
|
thread: null,
|
|
95
85
|
},
|
|
96
86
|
fields: metadata[metadataEnum.fields],
|
|
97
|
-
message:
|
|
87
|
+
message: errorLog ? errorLog.split('\n')[0] ?? '' : '',
|
|
98
88
|
muted: false,
|
|
99
89
|
params: metadata[metadataEnum.parameters],
|
|
90
|
+
group_params: metadata[metadataEnum.groupParameters],
|
|
100
91
|
relations: {
|
|
101
92
|
suite: {
|
|
102
93
|
data: [
|
|
@@ -108,7 +99,7 @@ class TestcafeQaseReporter {
|
|
|
108
99
|
},
|
|
109
100
|
},
|
|
110
101
|
run_id: null,
|
|
111
|
-
signature:
|
|
102
|
+
signature: this.getSignature(testRunInfo.fixture, title, metadata[metadataEnum.id], metadata[metadataEnum.parameters]),
|
|
112
103
|
steps: [],
|
|
113
104
|
id: (0, uuid_1.v4)(),
|
|
114
105
|
testops_id: metadata[metadataEnum.id].length > 0 ? metadata[metadataEnum.id] : null,
|
|
@@ -136,6 +127,7 @@ class TestcafeQaseReporter {
|
|
|
136
127
|
QaseTitle: undefined,
|
|
137
128
|
QaseFields: {},
|
|
138
129
|
QaseParameters: {},
|
|
130
|
+
QaseGroupParameters: {},
|
|
139
131
|
};
|
|
140
132
|
if (meta[metadataEnum.oldID] !== undefined && meta[metadataEnum.oldID] !== '') {
|
|
141
133
|
const v = meta[metadataEnum.oldID].split(',');
|
|
@@ -156,5 +148,35 @@ class TestcafeQaseReporter {
|
|
|
156
148
|
}
|
|
157
149
|
return metadata;
|
|
158
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* @param {FixtureType} fixture
|
|
153
|
+
* @param {string} title
|
|
154
|
+
* @param {number[]} ids
|
|
155
|
+
* @param {Record<string, string>} parameters
|
|
156
|
+
* @private
|
|
157
|
+
*/
|
|
158
|
+
getSignature(fixture, title, ids, parameters) {
|
|
159
|
+
const executionPath = process.cwd() + '/';
|
|
160
|
+
const path = fixture.path?.replace(executionPath, '') ?? '';
|
|
161
|
+
let signature = '';
|
|
162
|
+
if (path != '') {
|
|
163
|
+
signature += path.split('/').join('::') + '::';
|
|
164
|
+
}
|
|
165
|
+
signature += fixture.name.toLowerCase()
|
|
166
|
+
.replace(/\s/g, '_')
|
|
167
|
+
+ '::'
|
|
168
|
+
+ title.toLowerCase()
|
|
169
|
+
.replace(/\s/g, '_');
|
|
170
|
+
if (ids.length > 0) {
|
|
171
|
+
signature += `::${ids.join('::')}`;
|
|
172
|
+
}
|
|
173
|
+
if (Object.keys(parameters).length > 0) {
|
|
174
|
+
signature += '::';
|
|
175
|
+
}
|
|
176
|
+
signature += Object.entries(parameters)
|
|
177
|
+
.map(([key, value]) => `{${key}:${value}}`)
|
|
178
|
+
.join('::');
|
|
179
|
+
return signature;
|
|
180
|
+
}
|
|
159
181
|
}
|
|
160
182
|
exports.TestcafeQaseReporter = TestcafeQaseReporter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testcafe-reporter-qase",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Qase TMS TestCafe Reporter",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"author": "Qase Team <support@qase.io>",
|
|
41
41
|
"license": "Apache-2.0",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"qase-javascript-commons": "
|
|
43
|
+
"qase-javascript-commons": "~2.2.0",
|
|
44
44
|
"uuid": "^9.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|