@testomatio/reporter 2.0.1-beta.2 → 2.0.1-beta.4
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/lib/adapter/playwright.js +4 -0
- package/lib/client.js +5 -1
- package/lib/utils/utils.d.ts +7 -0
- package/lib/utils/utils.js +17 -2
- package/lib/xmlReader.js +1 -1
- package/package.json +4 -2
- package/src/adapter/playwright.js +4 -0
- package/src/client.js +7 -2
- package/src/utils/utils.js +15 -1
- package/src/xmlReader.js +1 -1
|
@@ -98,6 +98,10 @@ class PlaywrightReporter {
|
|
|
98
98
|
projectDependencies: project.dependencies?.length ? project.dependencies : null,
|
|
99
99
|
...testMeta,
|
|
100
100
|
...project.metadata, // metadata has any type (in playwright), but we will stringify it in client.js
|
|
101
|
+
...test.annotations?.reduce((acc, annotation) => {
|
|
102
|
+
acc[annotation.type] = annotation.description;
|
|
103
|
+
return acc;
|
|
104
|
+
}, {}),
|
|
101
105
|
},
|
|
102
106
|
file: test.location?.file,
|
|
103
107
|
});
|
package/lib/client.js
CHANGED
|
@@ -240,6 +240,9 @@ class Client {
|
|
|
240
240
|
uploadedFiles.push(this.uploader.uploadFileAsBuffer(buffer, [this.runId, rid, fileName]));
|
|
241
241
|
}
|
|
242
242
|
const artifacts = (await Promise.all(uploadedFiles)).filter(n => !!n);
|
|
243
|
+
const workspaceDir = process.env.TESTOMATIO_WORKDIR || process.cwd();
|
|
244
|
+
const relativeFile = file ? path_1.default.relative(workspaceDir, file) : file;
|
|
245
|
+
const rootSuiteId = (0, utils_js_1.validateSuiteId)(process.env.TESTOMATIO_SUITE);
|
|
243
246
|
const data = {
|
|
244
247
|
rid,
|
|
245
248
|
files,
|
|
@@ -247,7 +250,7 @@ class Client {
|
|
|
247
250
|
status,
|
|
248
251
|
stack: fullLogs,
|
|
249
252
|
example,
|
|
250
|
-
file,
|
|
253
|
+
file: relativeFile,
|
|
251
254
|
code,
|
|
252
255
|
title,
|
|
253
256
|
suite_title,
|
|
@@ -257,6 +260,7 @@ class Client {
|
|
|
257
260
|
run_time: typeof time === 'number' ? time : parseFloat(time),
|
|
258
261
|
artifacts,
|
|
259
262
|
meta,
|
|
263
|
+
...(rootSuiteId && { root_suite_id: rootSuiteId }),
|
|
260
264
|
};
|
|
261
265
|
// debug('Adding test run...', data);
|
|
262
266
|
// @ts-ignore
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export function getPackageVersion(): any;
|
|
2
2
|
export const TEST_ID_REGEX: RegExp;
|
|
3
|
+
export const SUITE_ID_REGEX: RegExp;
|
|
3
4
|
export function ansiRegExp(): RegExp;
|
|
4
5
|
export function isSameTest(test: any, t: any): boolean;
|
|
5
6
|
export function fetchSourceCode(contents: any, opts?: {}): string;
|
|
@@ -45,3 +46,9 @@ export function storeRunId(runId: any): void;
|
|
|
45
46
|
export namespace testRunnerHelper {
|
|
46
47
|
function getNameOfCurrentlyRunningTest(): any;
|
|
47
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Validates TESTOMATIO_SUITE environment variable format
|
|
51
|
+
* @param {String} suiteId - suite ID to validate
|
|
52
|
+
* @returns {String|null} validated suite ID or null if invalid
|
|
53
|
+
*/
|
|
54
|
+
export function validateSuiteId(suiteId: string): string | null;
|
package/lib/utils/utils.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.testRunnerHelper = exports.specificTestInfo = exports.parseSuite = exports.isValidUrl = exports.humanize = exports.getTestomatIdFromTestTitle = exports.getCurrentDateTime = exports.foundedTestLog = exports.fileSystem = exports.fetchFilesFromStackTrace = exports.fetchIdFromOutput = exports.fetchIdFromCode = exports.fetchSourceCodeFromStackTrace = exports.fetchSourceCode = exports.isSameTest = exports.ansiRegExp = exports.TEST_ID_REGEX = void 0;
|
|
39
|
+
exports.validateSuiteId = exports.testRunnerHelper = exports.specificTestInfo = exports.parseSuite = exports.isValidUrl = exports.humanize = exports.getTestomatIdFromTestTitle = exports.getCurrentDateTime = exports.foundedTestLog = exports.fileSystem = exports.fetchFilesFromStackTrace = exports.fetchIdFromOutput = exports.fetchIdFromCode = exports.fetchSourceCodeFromStackTrace = exports.fetchSourceCode = exports.isSameTest = exports.ansiRegExp = exports.SUITE_ID_REGEX = exports.TEST_ID_REGEX = void 0;
|
|
40
40
|
exports.getPackageVersion = getPackageVersion;
|
|
41
41
|
exports.formatStep = formatStep;
|
|
42
42
|
exports.readLatestRunId = readLatestRunId;
|
|
@@ -78,11 +78,23 @@ exports.getTestomatIdFromTestTitle = getTestomatIdFromTestTitle;
|
|
|
78
78
|
const parseSuite = suiteTitle => {
|
|
79
79
|
const captures = suiteTitle.match(/@S[\w\d]{8}/);
|
|
80
80
|
if (captures) {
|
|
81
|
-
return captures[
|
|
81
|
+
return captures[0];
|
|
82
82
|
}
|
|
83
83
|
return null;
|
|
84
84
|
};
|
|
85
85
|
exports.parseSuite = parseSuite;
|
|
86
|
+
/**
|
|
87
|
+
* Validates TESTOMATIO_SUITE environment variable format
|
|
88
|
+
* @param {String} suiteId - suite ID to validate
|
|
89
|
+
* @returns {String|null} validated suite ID or null if invalid
|
|
90
|
+
*/
|
|
91
|
+
const validateSuiteId = suiteId => {
|
|
92
|
+
if (!suiteId)
|
|
93
|
+
return null;
|
|
94
|
+
const match = suiteId.match(exports.SUITE_ID_REGEX);
|
|
95
|
+
return match ? match[0] : null;
|
|
96
|
+
};
|
|
97
|
+
exports.validateSuiteId = validateSuiteId;
|
|
86
98
|
const ansiRegExp = () => {
|
|
87
99
|
const pattern = [
|
|
88
100
|
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
|
@@ -157,6 +169,7 @@ const fetchSourceCodeFromStackTrace = (stack = '') => {
|
|
|
157
169
|
};
|
|
158
170
|
exports.fetchSourceCodeFromStackTrace = fetchSourceCodeFromStackTrace;
|
|
159
171
|
exports.TEST_ID_REGEX = /@T([\w\d]{8})/;
|
|
172
|
+
exports.SUITE_ID_REGEX = /@S([\w\d]{8})/;
|
|
160
173
|
const fetchIdFromCode = (code, opts = {}) => {
|
|
161
174
|
const comments = code
|
|
162
175
|
.split('\n')
|
|
@@ -426,6 +439,8 @@ module.exports.getTestomatIdFromTestTitle = getTestomatIdFromTestTitle;
|
|
|
426
439
|
|
|
427
440
|
module.exports.parseSuite = parseSuite;
|
|
428
441
|
|
|
442
|
+
module.exports.validateSuiteId = validateSuiteId;
|
|
443
|
+
|
|
429
444
|
module.exports.ansiRegExp = ansiRegExp;
|
|
430
445
|
|
|
431
446
|
module.exports.isValidUrl = isValidUrl;
|
package/lib/xmlReader.js
CHANGED
|
@@ -428,7 +428,7 @@ function reduceTestCases(prev, item) {
|
|
|
428
428
|
testCases
|
|
429
429
|
.filter(t => !!t)
|
|
430
430
|
.forEach(testCaseItem => {
|
|
431
|
-
const file = testCaseItem.file || item.filepath || item.fullname || '';
|
|
431
|
+
const file = testCaseItem.file || item.filepath || item.fullname || item.package || '';
|
|
432
432
|
let stack = '';
|
|
433
433
|
let message = '';
|
|
434
434
|
if (testCaseItem.error)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testomatio/reporter",
|
|
3
|
-
"version": "2.0.1-beta.
|
|
3
|
+
"version": "2.0.1-beta.4",
|
|
4
4
|
"description": "Testomatio Reporter Client",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -54,7 +54,9 @@
|
|
|
54
54
|
"lint": "eslint src",
|
|
55
55
|
"lint:fix": "eslint src --fix",
|
|
56
56
|
"format": "npm run lint:fix && npm run pretty:fix",
|
|
57
|
-
"test": "mocha tests/**",
|
|
57
|
+
"test": "mocha tests/** --ignore tests/adapter/playwright.test.js --ignore tests/adapter/codecept.test.js",
|
|
58
|
+
"test:frameworks": "mocha tests/adapter/playwright.test.js tests/adapter/codecept.test.js",
|
|
59
|
+
"install-example-deps": "cd example/playwright && npm install && cd ../codecept && npm install",
|
|
58
60
|
"init": "cd ./tests/adapter/examples/cucumber && npm i",
|
|
59
61
|
"test:adapter": "node node_modules/mocha/bin/mocha './tests/adapter/index.test.js'",
|
|
60
62
|
"test:pipes": "mocha './tests/pipes/*_test.js'",
|
|
@@ -102,6 +102,10 @@ class PlaywrightReporter {
|
|
|
102
102
|
projectDependencies: project.dependencies?.length ? project.dependencies : null,
|
|
103
103
|
...testMeta,
|
|
104
104
|
...project.metadata, // metadata has any type (in playwright), but we will stringify it in client.js
|
|
105
|
+
...test.annotations?.reduce((acc, annotation) => {
|
|
106
|
+
acc[annotation.type] = annotation.description;
|
|
107
|
+
return acc;
|
|
108
|
+
}, {}),
|
|
105
109
|
},
|
|
106
110
|
file: test.location?.file,
|
|
107
111
|
});
|
package/src/client.js
CHANGED
|
@@ -10,7 +10,7 @@ import { glob } from 'glob';
|
|
|
10
10
|
import path, { sep } from 'path';
|
|
11
11
|
import { fileURLToPath } from 'node:url';
|
|
12
12
|
import { S3Uploader } from './uploader.js';
|
|
13
|
-
import { formatStep, storeRunId } from './utils/utils.js';
|
|
13
|
+
import { formatStep, storeRunId, validateSuiteId } from './utils/utils.js';
|
|
14
14
|
import { filesize as prettyBytes } from 'filesize';
|
|
15
15
|
|
|
16
16
|
const debug = createDebugMessages('@testomatio/reporter:client');
|
|
@@ -245,6 +245,10 @@ class Client {
|
|
|
245
245
|
|
|
246
246
|
const artifacts = (await Promise.all(uploadedFiles)).filter(n => !!n);
|
|
247
247
|
|
|
248
|
+
const workspaceDir = process.env.TESTOMATIO_WORKDIR || process.cwd();
|
|
249
|
+
const relativeFile = file ? path.relative(workspaceDir, file) : file;
|
|
250
|
+
const rootSuiteId = validateSuiteId(process.env.TESTOMATIO_SUITE);
|
|
251
|
+
|
|
248
252
|
const data = {
|
|
249
253
|
rid,
|
|
250
254
|
files,
|
|
@@ -252,7 +256,7 @@ class Client {
|
|
|
252
256
|
status,
|
|
253
257
|
stack: fullLogs,
|
|
254
258
|
example,
|
|
255
|
-
file,
|
|
259
|
+
file: relativeFile,
|
|
256
260
|
code,
|
|
257
261
|
title,
|
|
258
262
|
suite_title,
|
|
@@ -262,6 +266,7 @@ class Client {
|
|
|
262
266
|
run_time: typeof time === 'number' ? time : parseFloat(time),
|
|
263
267
|
artifacts,
|
|
264
268
|
meta,
|
|
269
|
+
...(rootSuiteId && { root_suite_id: rootSuiteId }),
|
|
265
270
|
};
|
|
266
271
|
|
|
267
272
|
// debug('Adding test run...', data);
|
package/src/utils/utils.js
CHANGED
|
@@ -40,12 +40,24 @@ const getTestomatIdFromTestTitle = testTitle => {
|
|
|
40
40
|
const parseSuite = suiteTitle => {
|
|
41
41
|
const captures = suiteTitle.match(/@S[\w\d]{8}/);
|
|
42
42
|
if (captures) {
|
|
43
|
-
return captures[
|
|
43
|
+
return captures[0];
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
return null;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Validates TESTOMATIO_SUITE environment variable format
|
|
51
|
+
* @param {String} suiteId - suite ID to validate
|
|
52
|
+
* @returns {String|null} validated suite ID or null if invalid
|
|
53
|
+
*/
|
|
54
|
+
const validateSuiteId = suiteId => {
|
|
55
|
+
if (!suiteId) return null;
|
|
56
|
+
|
|
57
|
+
const match = suiteId.match(SUITE_ID_REGEX);
|
|
58
|
+
return match ? match[0] : null;
|
|
59
|
+
};
|
|
60
|
+
|
|
49
61
|
const ansiRegExp = () => {
|
|
50
62
|
const pattern = [
|
|
51
63
|
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
|
@@ -124,6 +136,7 @@ const fetchSourceCodeFromStackTrace = (stack = '') => {
|
|
|
124
136
|
};
|
|
125
137
|
|
|
126
138
|
export const TEST_ID_REGEX = /@T([\w\d]{8})/;
|
|
139
|
+
export const SUITE_ID_REGEX = /@S([\w\d]{8})/;
|
|
127
140
|
|
|
128
141
|
const fetchIdFromCode = (code, opts = {}) => {
|
|
129
142
|
const comments = code
|
|
@@ -399,4 +412,5 @@ export {
|
|
|
399
412
|
specificTestInfo,
|
|
400
413
|
storeRunId,
|
|
401
414
|
testRunnerHelper,
|
|
415
|
+
validateSuiteId,
|
|
402
416
|
};
|
package/src/xmlReader.js
CHANGED
|
@@ -483,7 +483,7 @@ function reduceTestCases(prev, item) {
|
|
|
483
483
|
testCases
|
|
484
484
|
.filter(t => !!t)
|
|
485
485
|
.forEach(testCaseItem => {
|
|
486
|
-
const file = testCaseItem.file || item.filepath || item.fullname || '';
|
|
486
|
+
const file = testCaseItem.file || item.filepath || item.fullname || item.package || '';
|
|
487
487
|
|
|
488
488
|
let stack = '';
|
|
489
489
|
let message = '';
|