@testomatio/reporter 2.0.1-beta.5-timestamp → 2.0.1-beta.7
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 +1 -0
- package/lib/adapter/codecept.d.ts +2 -0
- package/lib/adapter/codecept.js +297 -335
- package/lib/adapter/cucumber/current.d.ts +14 -0
- package/lib/adapter/cucumber/current.js +195 -203
- package/lib/adapter/cucumber/legacy.d.ts +0 -0
- package/lib/adapter/cucumber/legacy.js +130 -155
- package/lib/adapter/cucumber.d.ts +2 -0
- package/lib/adapter/cucumber.js +5 -16
- package/lib/adapter/cypress-plugin/index.d.ts +2 -0
- package/lib/adapter/cypress-plugin/index.js +91 -105
- package/lib/adapter/jasmine.d.ts +11 -0
- package/lib/adapter/jasmine.js +54 -53
- package/lib/adapter/jest.d.ts +13 -0
- package/lib/adapter/jest.js +97 -99
- package/lib/adapter/mocha.d.ts +2 -0
- package/lib/adapter/mocha.js +112 -141
- package/lib/adapter/nightwatch.d.ts +4 -0
- package/lib/adapter/nightwatch.js +80 -0
- package/lib/adapter/playwright.d.ts +14 -0
- package/lib/adapter/playwright.js +208 -231
- package/lib/adapter/vitest.d.ts +35 -0
- package/lib/adapter/vitest.js +150 -149
- package/lib/adapter/webdriver.d.ts +24 -0
- package/lib/adapter/webdriver.js +144 -121
- package/lib/bin/cli.d.ts +2 -0
- package/lib/bin/cli.js +229 -211
- package/lib/bin/reportXml.d.ts +2 -0
- package/lib/bin/reportXml.js +51 -52
- package/lib/bin/startTest.d.ts +2 -0
- package/lib/bin/startTest.js +83 -95
- package/lib/bin/uploadArtifacts.d.ts +2 -0
- package/lib/bin/uploadArtifacts.js +56 -61
- package/lib/client.d.ts +76 -0
- package/lib/client.js +431 -465
- package/lib/config.d.ts +1 -0
- package/lib/config.js +18 -23
- package/lib/constants.d.ts +25 -0
- package/lib/constants.js +50 -44
- package/lib/data-storage.d.ts +34 -0
- package/lib/data-storage.js +216 -188
- package/lib/junit-adapter/adapter.d.ts +9 -0
- package/lib/junit-adapter/adapter.js +17 -20
- package/lib/junit-adapter/csharp.d.ts +5 -0
- package/lib/junit-adapter/csharp.js +28 -14
- package/lib/junit-adapter/index.d.ts +3 -0
- package/lib/junit-adapter/index.js +27 -25
- package/lib/junit-adapter/java.d.ts +5 -0
- package/lib/junit-adapter/java.js +41 -53
- package/lib/junit-adapter/javascript.d.ts +4 -0
- package/lib/junit-adapter/javascript.js +30 -27
- package/lib/junit-adapter/python.d.ts +5 -0
- package/lib/junit-adapter/python.js +38 -37
- package/lib/junit-adapter/ruby.d.ts +4 -0
- package/lib/junit-adapter/ruby.js +11 -8
- package/lib/output.d.ts +11 -0
- package/lib/output.js +44 -52
- package/lib/package.json +3 -0
- package/lib/pipe/bitbucket.d.ts +25 -0
- package/lib/pipe/bitbucket.js +223 -230
- package/lib/pipe/csv.d.ts +47 -0
- package/lib/pipe/csv.js +113 -126
- package/lib/pipe/debug.d.ts +29 -0
- package/lib/pipe/debug.js +125 -99
- package/lib/pipe/github.d.ts +30 -0
- package/lib/pipe/github.js +218 -213
- package/lib/pipe/gitlab.d.ts +25 -0
- package/lib/pipe/gitlab.js +183 -206
- package/lib/pipe/html.d.ts +35 -0
- package/lib/pipe/html.js +258 -321
- package/lib/pipe/index.d.ts +1 -0
- package/lib/pipe/index.js +94 -66
- package/lib/pipe/testomatio.d.ts +71 -0
- package/lib/pipe/testomatio.js +429 -474
- package/lib/replay.d.ts +31 -0
- package/lib/replay.js +255 -0
- package/lib/reporter-functions.d.ts +41 -0
- package/lib/reporter-functions.js +64 -26
- package/lib/reporter.d.ts +235 -0
- package/lib/reporter.js +37 -29
- package/lib/services/artifacts.d.ts +33 -0
- package/lib/services/artifacts.js +55 -51
- package/lib/services/index.d.ts +11 -0
- package/lib/services/index.js +16 -12
- package/lib/services/key-values.d.ts +27 -0
- package/lib/services/key-values.js +56 -53
- package/lib/services/labels.d.ts +22 -0
- package/lib/services/labels.js +62 -0
- package/lib/services/logger.d.ts +64 -0
- package/lib/services/logger.js +226 -245
- package/lib/template/testomatio.hbs +1026 -1366
- package/lib/uploader.d.ts +60 -0
- package/lib/uploader.js +295 -364
- package/lib/utils/pipe_utils.d.ts +41 -0
- package/lib/utils/pipe_utils.js +89 -85
- package/lib/utils/utils.d.ts +54 -0
- package/lib/utils/utils.js +398 -307
- package/lib/xmlReader.d.ts +92 -0
- package/lib/xmlReader.js +525 -532
- package/package.json +64 -21
- package/src/adapter/codecept.js +377 -0
- package/src/adapter/cucumber/current.js +228 -0
- package/src/adapter/cucumber/legacy.js +158 -0
- package/src/adapter/cucumber.js +4 -0
- package/src/adapter/cypress-plugin/index.js +110 -0
- package/src/adapter/jasmine.js +60 -0
- package/src/adapter/jest.js +107 -0
- package/src/adapter/mocha.cjs +2 -0
- package/src/adapter/mocha.js +156 -0
- package/src/adapter/nightwatch.js +88 -0
- package/src/adapter/playwright.js +258 -0
- package/src/adapter/vitest.js +183 -0
- package/src/adapter/webdriver.js +142 -0
- package/src/bin/cli.js +348 -0
- package/src/bin/reportXml.js +77 -0
- package/src/bin/startTest.js +124 -0
- package/src/bin/uploadArtifacts.js +91 -0
- package/src/client.js +519 -0
- package/src/config.js +30 -0
- package/src/constants.js +53 -0
- package/src/data-storage.js +204 -0
- package/src/junit-adapter/adapter.js +23 -0
- package/src/junit-adapter/csharp.js +28 -0
- package/src/junit-adapter/index.js +28 -0
- package/src/junit-adapter/java.js +58 -0
- package/src/junit-adapter/javascript.js +31 -0
- package/src/junit-adapter/python.js +42 -0
- package/src/junit-adapter/ruby.js +10 -0
- package/src/output.js +57 -0
- package/src/pipe/bitbucket.js +252 -0
- package/src/pipe/csv.js +140 -0
- package/src/pipe/debug.js +125 -0
- package/src/pipe/github.js +232 -0
- package/src/pipe/gitlab.js +247 -0
- package/src/pipe/html.js +373 -0
- package/src/pipe/index.js +71 -0
- package/src/pipe/testomatio.js +504 -0
- package/src/replay.js +262 -0
- package/src/reporter-functions.js +96 -0
- package/src/reporter.cjs_decprecated +21 -0
- package/src/reporter.js +36 -0
- package/src/services/artifacts.js +59 -0
- package/src/services/index.js +15 -0
- package/src/services/key-values.js +59 -0
- package/src/services/labels.js +59 -0
- package/src/services/logger.js +315 -0
- package/src/template/emptyData.svg +23 -0
- package/src/template/testomatio.hbs +1081 -0
- package/src/uploader.js +376 -0
- package/src/utils/pipe_utils.js +119 -0
- package/src/utils/utils.js +416 -0
- package/src/xmlReader.js +614 -0
|
@@ -1,255 +1,232 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const uuid_1 = require("uuid");
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const constants_js_1 = require("../constants.js");
|
|
13
|
+
const client_js_1 = __importDefault(require("../client.js"));
|
|
14
|
+
const utils_js_1 = require("../utils/utils.js");
|
|
15
|
+
const index_js_1 = require("../services/index.js");
|
|
16
|
+
const data_storage_js_1 = require("../data-storage.js");
|
|
14
17
|
const reportTestPromises = [];
|
|
15
|
-
|
|
16
18
|
class PlaywrightReporter {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.uploads = [];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
onBegin(config, suite) {
|
|
24
|
-
// clean data storage
|
|
25
|
-
fileSystem.clearDir(TESTOMAT_TMP_STORAGE_DIR);
|
|
26
|
-
if (!this.client) return;
|
|
27
|
-
this.suite = suite;
|
|
28
|
-
this.config = config;
|
|
29
|
-
this.client.createRun();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
onTestBegin(testInfo) {
|
|
33
|
-
const fullTestTitle = getTestContextName(testInfo);
|
|
34
|
-
dataStorage.setContext(fullTestTitle);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
onTestEnd(test, result) {
|
|
38
|
-
if (!this.client) return;
|
|
39
|
-
|
|
40
|
-
const { title } = test;
|
|
41
|
-
const { error, duration } = result;
|
|
42
|
-
const suite_title = test.parent ? test.parent?.title : path.basename(test?.location?.file);
|
|
43
|
-
|
|
44
|
-
const steps = [];
|
|
45
|
-
for (const step of result.steps) {
|
|
46
|
-
const appendedStep = appendStep(step);
|
|
47
|
-
if (appendedStep) {
|
|
48
|
-
steps.push(appendedStep);
|
|
49
|
-
}
|
|
19
|
+
constructor(config = {}) {
|
|
20
|
+
this.client = new client_js_1.default({ apiKey: config?.apiKey });
|
|
21
|
+
this.uploads = [];
|
|
50
22
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
23
|
+
onBegin(config, suite) {
|
|
24
|
+
// clean data storage
|
|
25
|
+
utils_js_1.fileSystem.clearDir(constants_js_1.TESTOMAT_TMP_STORAGE_DIR);
|
|
26
|
+
if (!this.client)
|
|
27
|
+
return;
|
|
28
|
+
this.suite = suite;
|
|
29
|
+
this.config = config;
|
|
30
|
+
this.client.createRun();
|
|
56
31
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @type {{
|
|
63
|
-
* browser?: string,
|
|
64
|
-
* dependencies: string[],
|
|
65
|
-
* isMobile?: boolean
|
|
66
|
-
* metadata: Record<string, any>,
|
|
67
|
-
* name: string,
|
|
68
|
-
* }}
|
|
69
|
-
*/
|
|
70
|
-
const project = {
|
|
71
|
-
browser: test.parent.project().use.defaultBrowserType,
|
|
72
|
-
dependencies: test.parent.project().dependencies,
|
|
73
|
-
isMobile: test.parent.project().use.isMobile,
|
|
74
|
-
metadata: test.parent.project().metadata,
|
|
75
|
-
name: test.parent.project().name,
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const reportTestPromise = this.client.addTestRun(checkStatus(result.status), {
|
|
79
|
-
rid: `${rid}-${project.name}`,
|
|
80
|
-
error,
|
|
81
|
-
test_id: getTestomatIdFromTestTitle(`${title} ${test.tags?.join(' ')}`),
|
|
82
|
-
suite_title,
|
|
83
|
-
title,
|
|
84
|
-
steps: steps.length ? steps : undefined,
|
|
85
|
-
time: duration,
|
|
86
|
-
logs,
|
|
87
|
-
manuallyAttachedArtifacts,
|
|
88
|
-
meta: {
|
|
89
|
-
browser: project.browser,
|
|
90
|
-
isMobile: project.isMobile,
|
|
91
|
-
project: project.name,
|
|
92
|
-
projectDependencies: project.dependencies?.length ? project.dependencies : null,
|
|
93
|
-
...testMeta,
|
|
94
|
-
...project.metadata, // metadata has any type (in playwright), but we will stringify it in client.js
|
|
95
|
-
},
|
|
96
|
-
file: test.location?.file,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
this.uploads.push({
|
|
100
|
-
rid: `${rid}-${project.name}`,
|
|
101
|
-
title: test.title,
|
|
102
|
-
files: result.attachments.filter(a => a.body || a.path),
|
|
103
|
-
file: test.location?.file,
|
|
104
|
-
});
|
|
105
|
-
// remove empty uploads
|
|
106
|
-
this.uploads = this.uploads.filter(upload => upload.files.length);
|
|
107
|
-
|
|
108
|
-
reportTestPromises.push(reportTestPromise);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
#getArtifactPath(artifact) {
|
|
112
|
-
if (artifact.path) {
|
|
113
|
-
if (path.isAbsolute(artifact.path)) return artifact.path;
|
|
114
|
-
|
|
115
|
-
return path.join(this.config.outputDir || this.config.projects[0].outputDir, artifact.path);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (artifact.body) {
|
|
119
|
-
let filePath = generateTmpFilepath(artifact.name);
|
|
120
|
-
|
|
121
|
-
const extension = artifact.contentType?.split('/')[1]?.replace('jpeg', 'jpg');
|
|
122
|
-
if (extension) filePath += `.${extension}`;
|
|
123
|
-
|
|
124
|
-
fs.writeFileSync(filePath, artifact.body);
|
|
125
|
-
return filePath;
|
|
32
|
+
onTestBegin(testInfo) {
|
|
33
|
+
const fullTestTitle = getTestContextName(testInfo);
|
|
34
|
+
data_storage_js_1.dataStorage.setContext(fullTestTitle);
|
|
126
35
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
36
|
+
onTestEnd(test, result) {
|
|
37
|
+
// test.parent.project().__projectId
|
|
38
|
+
if (!this.client)
|
|
39
|
+
return;
|
|
40
|
+
const { title } = test;
|
|
41
|
+
const { error, duration } = result;
|
|
42
|
+
const suite_title = test.parent ? test.parent?.title : path_1.default.basename(test?.location?.file);
|
|
43
|
+
const steps = [];
|
|
44
|
+
for (const step of result.steps) {
|
|
45
|
+
const appendedStep = appendStep(step);
|
|
46
|
+
if (appendedStep) {
|
|
47
|
+
steps.push(appendedStep);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const fullTestTitle = getTestContextName(test);
|
|
51
|
+
let logs = '';
|
|
52
|
+
if (result.stderr.length || result.stdout.length) {
|
|
53
|
+
logs = `\n\n${picocolors_1.default.bold('Logs:')}\n${picocolors_1.default.red(result.stderr.join(''))}\n${result.stdout.join('')}`;
|
|
54
|
+
}
|
|
55
|
+
const manuallyAttachedArtifacts = index_js_1.services.artifacts.get(fullTestTitle);
|
|
56
|
+
const testMeta = index_js_1.services.keyValues.get(fullTestTitle);
|
|
57
|
+
const rid = test.id || test.testId || (0, uuid_1.v4)();
|
|
58
|
+
/**
|
|
59
|
+
* @type {{
|
|
60
|
+
* browser?: string,
|
|
61
|
+
* dependencies: string[],
|
|
62
|
+
* isMobile?: boolean
|
|
63
|
+
* metadata: Record<string, any>,
|
|
64
|
+
* name: string,
|
|
65
|
+
* }}
|
|
66
|
+
*/
|
|
67
|
+
const project = {
|
|
68
|
+
browser: test.parent.project().use.defaultBrowserType,
|
|
69
|
+
dependencies: test.parent.project().dependencies,
|
|
70
|
+
isMobile: test.parent.project().use.isMobile,
|
|
71
|
+
metadata: test.parent.project().metadata,
|
|
72
|
+
name: test.parent.project().name,
|
|
73
|
+
};
|
|
74
|
+
let status = result.status;
|
|
75
|
+
// process test.fail() annotation
|
|
76
|
+
if (test.expectedStatus === 'failed') {
|
|
77
|
+
// actual status = expected
|
|
78
|
+
if (result.status === 'failed')
|
|
79
|
+
status = 'passed';
|
|
80
|
+
// actual status != expected
|
|
81
|
+
if (result.status === 'passed')
|
|
82
|
+
status = 'failed';
|
|
154
83
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
84
|
+
const reportTestPromise = this.client.addTestRun(checkStatus(status), {
|
|
85
|
+
rid: `${rid}-${project.name}`,
|
|
86
|
+
error,
|
|
87
|
+
test_id: (0, utils_js_1.getTestomatIdFromTestTitle)(`${title} ${test.tags?.join(' ')}`),
|
|
88
|
+
suite_title,
|
|
159
89
|
title,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
90
|
+
steps: steps.length ? steps : undefined,
|
|
91
|
+
time: duration,
|
|
92
|
+
logs,
|
|
93
|
+
manuallyAttachedArtifacts,
|
|
94
|
+
meta: {
|
|
95
|
+
browser: project.browser,
|
|
96
|
+
isMobile: project.isMobile,
|
|
97
|
+
project: project.name,
|
|
98
|
+
projectDependencies: project.dependencies?.length ? project.dependencies : null,
|
|
99
|
+
...testMeta,
|
|
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
|
+
}, {}),
|
|
105
|
+
},
|
|
106
|
+
file: test.location?.file,
|
|
107
|
+
});
|
|
108
|
+
this.uploads.push({
|
|
109
|
+
rid: `${rid}-${project.name}`,
|
|
110
|
+
title: test.title,
|
|
111
|
+
files: result.attachments.filter(a => a.body || a.path),
|
|
112
|
+
file: test.location?.file,
|
|
113
|
+
});
|
|
114
|
+
// remove empty uploads
|
|
115
|
+
this.uploads = this.uploads.filter(anUpload => anUpload.files.length);
|
|
116
|
+
reportTestPromises.push(reportTestPromise);
|
|
117
|
+
}
|
|
118
|
+
#getArtifactPath(artifact) {
|
|
119
|
+
if (artifact.path) {
|
|
120
|
+
if (path_1.default.isAbsolute(artifact.path))
|
|
121
|
+
return artifact.path;
|
|
122
|
+
return path_1.default.join(this.config.outputDir || this.config.projects[0].outputDir, artifact.path);
|
|
123
|
+
}
|
|
124
|
+
if (artifact.body) {
|
|
125
|
+
let filePath = generateTmpFilepath(artifact.name);
|
|
126
|
+
// Check if file already has an extension
|
|
127
|
+
const hasExtension = artifact.name && path_1.default.extname(artifact.name);
|
|
128
|
+
if (!hasExtension && artifact.contentType) {
|
|
129
|
+
const mimeType = artifact.contentType.split('/')[1];
|
|
130
|
+
const extensionMap = {
|
|
131
|
+
jpeg: 'jpg',
|
|
132
|
+
plain: 'txt',
|
|
133
|
+
};
|
|
134
|
+
const extension = extensionMap[mimeType] || mimeType;
|
|
135
|
+
if (extension)
|
|
136
|
+
filePath += `.${extension}`;
|
|
137
|
+
}
|
|
138
|
+
fs_1.default.writeFileSync(filePath, artifact.body);
|
|
139
|
+
return filePath;
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
async onEnd(result) {
|
|
144
|
+
if (!this.client)
|
|
145
|
+
return;
|
|
146
|
+
await Promise.all(reportTestPromises);
|
|
147
|
+
if (this.uploads.length) {
|
|
148
|
+
if (this.client.uploader.isEnabled)
|
|
149
|
+
console.log(constants_js_1.APP_PREFIX, `🎞️ Uploading ${this.uploads.length} files...`);
|
|
150
|
+
const promises = [];
|
|
151
|
+
// ? possible move to addTestRun (needs investigation if files are ready)
|
|
152
|
+
for (const upload of this.uploads) {
|
|
153
|
+
const { rid, file, title } = upload;
|
|
154
|
+
const files = upload.files.map(attachment => ({
|
|
155
|
+
path: this.#getArtifactPath(attachment),
|
|
156
|
+
title,
|
|
157
|
+
type: attachment.contentType,
|
|
158
|
+
}));
|
|
159
|
+
if (!this.client.uploader.isEnabled) {
|
|
160
|
+
files.forEach(f => this.client.uploader.storeUploadedFile(f, this.client.runId, rid, false));
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
promises.push(this.client.addTestRun(undefined, {
|
|
164
|
+
rid,
|
|
165
|
+
title,
|
|
166
|
+
files,
|
|
167
|
+
file,
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
await Promise.all(promises);
|
|
171
|
+
}
|
|
172
|
+
await this.client.updateRunStatus(checkStatus(result.status));
|
|
166
173
|
}
|
|
167
|
-
|
|
168
|
-
await this.client.updateRunStatus(checkStatus(result.status));
|
|
169
|
-
}
|
|
170
174
|
}
|
|
171
|
-
|
|
172
175
|
function checkStatus(status) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}[status] || Status.FAILED
|
|
179
|
-
);
|
|
176
|
+
return ({
|
|
177
|
+
skipped: constants_js_1.STATUS.SKIPPED,
|
|
178
|
+
timedOut: constants_js_1.STATUS.FAILED,
|
|
179
|
+
passed: constants_js_1.STATUS.PASSED,
|
|
180
|
+
}[status] || constants_js_1.STATUS.FAILED);
|
|
180
181
|
}
|
|
181
|
-
|
|
182
182
|
function appendStep(step, shift = 0) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
183
|
+
// nesting too deep, ignore those steps
|
|
184
|
+
if (shift >= 10)
|
|
185
|
+
return;
|
|
186
|
+
let newCategory = step.category;
|
|
187
|
+
switch (newCategory) {
|
|
188
|
+
case 'test.step':
|
|
189
|
+
newCategory = 'user';
|
|
190
|
+
break;
|
|
191
|
+
case 'hook':
|
|
192
|
+
newCategory = 'hook';
|
|
193
|
+
break;
|
|
194
|
+
case 'attach':
|
|
195
|
+
return null; // Skip steps with category 'attach'
|
|
196
|
+
default:
|
|
197
|
+
newCategory = 'framework';
|
|
198
|
+
}
|
|
199
|
+
const formattedSteps = [];
|
|
200
|
+
for (const child of step.steps || []) {
|
|
201
|
+
const appendedChild = appendStep(child, shift + 2);
|
|
202
|
+
if (appendedChild) {
|
|
203
|
+
formattedSteps.push(appendedChild);
|
|
204
|
+
}
|
|
205
205
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (step.error !== undefined) {
|
|
219
|
-
resultStep.error = step.error;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return resultStep;
|
|
206
|
+
const resultStep = {
|
|
207
|
+
category: newCategory,
|
|
208
|
+
title: step.title,
|
|
209
|
+
duration: step.duration,
|
|
210
|
+
};
|
|
211
|
+
if (formattedSteps.length) {
|
|
212
|
+
resultStep.steps = formattedSteps.filter(s => !!s);
|
|
213
|
+
}
|
|
214
|
+
if (step.error !== undefined) {
|
|
215
|
+
resultStep.error = step.error;
|
|
216
|
+
}
|
|
217
|
+
return resultStep;
|
|
223
218
|
}
|
|
224
|
-
|
|
225
219
|
function generateTmpFilepath(filename = '') {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
220
|
+
filename = filename || `tmp.${crypto_1.default.randomBytes(16).toString('hex')}`;
|
|
221
|
+
const tmpdir = os_1.default.tmpdir();
|
|
222
|
+
return path_1.default.join(tmpdir, filename);
|
|
229
223
|
}
|
|
230
|
-
|
|
231
224
|
/**
|
|
232
225
|
* Returns filename + test title
|
|
233
226
|
* @param {*} test - testInfo object from Playwright
|
|
234
227
|
* @returns
|
|
235
228
|
*/
|
|
236
229
|
function getTestContextName(test) {
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function initPlaywrightForStorage() {
|
|
241
|
-
try {
|
|
242
|
-
// @ts-ignore-next-line
|
|
243
|
-
// eslint-disable-next-line import/no-unresolved
|
|
244
|
-
const { test } = require('@playwright/test');
|
|
245
|
-
// eslint-disable-next-line no-empty-pattern
|
|
246
|
-
test.beforeEach(async ({}, testInfo) => {
|
|
247
|
-
global.testomatioTestTitle = `${testInfo.file || ''}_${testInfo.title}`;
|
|
248
|
-
});
|
|
249
|
-
} catch (e) {
|
|
250
|
-
// ignore
|
|
251
|
-
}
|
|
230
|
+
return `${test._requireFile || ''}_${test.title}`;
|
|
252
231
|
}
|
|
253
|
-
|
|
254
232
|
module.exports = PlaywrightReporter;
|
|
255
|
-
module.exports.initPlaywrightForStorage = initPlaywrightForStorage;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export default VitestReporter;
|
|
2
|
+
export type VitestTest = import("../../types/types.js").VitestTest;
|
|
3
|
+
export type VitestTestFile = import("../../types/types.js").VitestTestFile;
|
|
4
|
+
export type VitestSuite = import("../../types/types.js").VitestSuite;
|
|
5
|
+
export type VitestTestLogs = import("../../types/types.js").VitestTestLogs;
|
|
6
|
+
export type ErrorWithDiff = import("../../types/vitest.types.js").ErrorWithDiff;
|
|
7
|
+
export type STATUS = typeof import("../constants.js").STATUS;
|
|
8
|
+
export type TestData = import("../../types/types.js").TestData;
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {import('../../types/types.js').VitestTest} VitestTest
|
|
11
|
+
* @typedef {import('../../types/types.js').VitestTestFile} VitestTestFile
|
|
12
|
+
* @typedef {import('../../types/types.js').VitestSuite} VitestSuite
|
|
13
|
+
* @typedef {import('../../types/types.js').VitestTestLogs} VitestTestLogs
|
|
14
|
+
* @typedef {import('../../types/vitest.types.js').ErrorWithDiff} ErrorWithDiff
|
|
15
|
+
* @typedef {typeof import('../constants.js').STATUS} STATUS
|
|
16
|
+
* @typedef {import('../../types/types.js').TestData} TestData
|
|
17
|
+
*/
|
|
18
|
+
export class VitestReporter {
|
|
19
|
+
constructor(config?: {});
|
|
20
|
+
client: TestomatioClient;
|
|
21
|
+
/**
|
|
22
|
+
* @type {(TestData & {status: string})[]} tests
|
|
23
|
+
*/
|
|
24
|
+
tests: (TestData & {
|
|
25
|
+
status: string;
|
|
26
|
+
})[];
|
|
27
|
+
onInit(): void;
|
|
28
|
+
/**
|
|
29
|
+
* @param {VitestTestFile[] | undefined} files // array with results;
|
|
30
|
+
* @param {unknown[] | undefined} errors // errors does not contain errors from tests; probably its testrunner errors
|
|
31
|
+
*/
|
|
32
|
+
onFinished(files: VitestTestFile[] | undefined, errors: unknown[] | undefined): Promise<void>;
|
|
33
|
+
#private;
|
|
34
|
+
}
|
|
35
|
+
import { Client as TestomatioClient } from '../client.js';
|