@testomatio/reporter 2.0.1-beta.4 → 2.0.1-beta.5-timestamp
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/codecept.js +335 -293
- package/lib/adapter/cucumber/current.js +203 -195
- package/lib/adapter/cucumber/legacy.js +155 -130
- package/lib/adapter/cucumber.js +16 -5
- package/lib/adapter/cypress-plugin/index.js +105 -91
- package/lib/adapter/jasmine.js +53 -54
- package/lib/adapter/jest.js +99 -97
- package/lib/adapter/mocha.js +141 -112
- package/lib/adapter/playwright.js +231 -199
- package/lib/adapter/vitest.js +149 -150
- package/lib/adapter/webdriver.js +121 -144
- package/lib/bin/cli.js +211 -229
- package/lib/bin/reportXml.js +52 -51
- package/lib/bin/startTest.js +95 -83
- package/lib/bin/uploadArtifacts.js +61 -56
- package/lib/client.js +465 -424
- package/lib/config.js +23 -18
- package/lib/constants.js +44 -50
- package/lib/data-storage.js +188 -216
- package/lib/junit-adapter/adapter.js +20 -17
- package/lib/junit-adapter/csharp.js +14 -28
- package/lib/junit-adapter/index.js +25 -27
- package/lib/junit-adapter/java.js +53 -41
- package/lib/junit-adapter/javascript.js +27 -30
- package/lib/junit-adapter/python.js +37 -38
- package/lib/junit-adapter/ruby.js +8 -11
- package/lib/output.js +52 -44
- package/lib/pipe/bitbucket.js +230 -223
- package/lib/pipe/csv.js +126 -113
- package/lib/pipe/debug.js +99 -118
- package/lib/pipe/github.js +213 -218
- package/lib/pipe/gitlab.js +206 -183
- package/lib/pipe/html.js +321 -258
- package/lib/pipe/index.js +66 -94
- package/lib/pipe/testomatio.js +474 -429
- package/lib/reporter-functions.js +26 -28
- package/lib/reporter.js +29 -34
- package/lib/services/artifacts.js +51 -55
- package/lib/services/index.js +12 -14
- package/lib/services/key-values.js +53 -56
- package/lib/services/logger.js +245 -226
- package/lib/template/testomatio.hbs +1366 -1026
- package/lib/uploader.js +364 -295
- package/lib/utils/pipe_utils.js +85 -89
- package/lib/utils/utils.js +307 -398
- package/lib/xmlReader.js +532 -525
- package/package.json +21 -64
- package/lib/adapter/codecept.d.ts +0 -2
- package/lib/adapter/cucumber/current.d.ts +0 -14
- package/lib/adapter/cucumber/legacy.d.ts +0 -0
- package/lib/adapter/cucumber.d.ts +0 -2
- package/lib/adapter/cypress-plugin/index.d.ts +0 -2
- package/lib/adapter/jasmine.d.ts +0 -11
- package/lib/adapter/jest.d.ts +0 -13
- package/lib/adapter/mocha.d.ts +0 -2
- package/lib/adapter/nightwatch.d.ts +0 -4
- package/lib/adapter/nightwatch.js +0 -80
- package/lib/adapter/playwright.d.ts +0 -14
- package/lib/adapter/vitest.d.ts +0 -35
- package/lib/adapter/webdriver.d.ts +0 -24
- package/lib/bin/cli.d.ts +0 -2
- package/lib/bin/reportXml.d.ts +0 -2
- package/lib/bin/startTest.d.ts +0 -2
- package/lib/bin/uploadArtifacts.d.ts +0 -2
- package/lib/client.d.ts +0 -76
- package/lib/config.d.ts +0 -1
- package/lib/constants.d.ts +0 -25
- package/lib/data-storage.d.ts +0 -34
- package/lib/junit-adapter/adapter.d.ts +0 -9
- package/lib/junit-adapter/csharp.d.ts +0 -5
- package/lib/junit-adapter/index.d.ts +0 -3
- package/lib/junit-adapter/java.d.ts +0 -5
- package/lib/junit-adapter/javascript.d.ts +0 -4
- package/lib/junit-adapter/python.d.ts +0 -5
- package/lib/junit-adapter/ruby.d.ts +0 -4
- package/lib/output.d.ts +0 -11
- package/lib/package.json +0 -3
- package/lib/pipe/bitbucket.d.ts +0 -25
- package/lib/pipe/csv.d.ts +0 -47
- package/lib/pipe/debug.d.ts +0 -29
- package/lib/pipe/github.d.ts +0 -30
- package/lib/pipe/gitlab.d.ts +0 -25
- package/lib/pipe/html.d.ts +0 -35
- package/lib/pipe/index.d.ts +0 -1
- package/lib/pipe/testomatio.d.ts +0 -71
- package/lib/replay.d.ts +0 -31
- package/lib/replay.js +0 -237
- package/lib/reporter-functions.d.ts +0 -34
- package/lib/reporter.d.ts +0 -232
- package/lib/services/artifacts.d.ts +0 -33
- package/lib/services/index.d.ts +0 -9
- package/lib/services/key-values.d.ts +0 -27
- package/lib/services/logger.d.ts +0 -64
- package/lib/uploader.d.ts +0 -60
- package/lib/utils/pipe_utils.d.ts +0 -41
- package/lib/utils/utils.d.ts +0 -54
- package/lib/xmlReader.d.ts +0 -92
- package/src/adapter/codecept.js +0 -373
- package/src/adapter/cucumber/current.js +0 -228
- package/src/adapter/cucumber/legacy.js +0 -158
- package/src/adapter/cucumber.js +0 -4
- package/src/adapter/cypress-plugin/index.js +0 -110
- package/src/adapter/jasmine.js +0 -60
- package/src/adapter/jest.js +0 -107
- package/src/adapter/mocha.cjs +0 -2
- package/src/adapter/mocha.js +0 -156
- package/src/adapter/nightwatch.js +0 -88
- package/src/adapter/playwright.js +0 -254
- package/src/adapter/vitest.js +0 -183
- package/src/adapter/webdriver.js +0 -142
- package/src/bin/cli.js +0 -348
- package/src/bin/reportXml.js +0 -77
- package/src/bin/startTest.js +0 -124
- package/src/bin/uploadArtifacts.js +0 -91
- package/src/client.js +0 -508
- package/src/config.js +0 -30
- package/src/constants.js +0 -53
- package/src/data-storage.js +0 -204
- package/src/junit-adapter/adapter.js +0 -23
- package/src/junit-adapter/csharp.js +0 -28
- package/src/junit-adapter/index.js +0 -28
- package/src/junit-adapter/java.js +0 -58
- package/src/junit-adapter/javascript.js +0 -31
- package/src/junit-adapter/python.js +0 -42
- package/src/junit-adapter/ruby.js +0 -10
- package/src/output.js +0 -57
- package/src/pipe/bitbucket.js +0 -252
- package/src/pipe/csv.js +0 -140
- package/src/pipe/debug.js +0 -119
- package/src/pipe/github.js +0 -232
- package/src/pipe/gitlab.js +0 -247
- package/src/pipe/html.js +0 -373
- package/src/pipe/index.js +0 -71
- package/src/pipe/testomatio.js +0 -504
- package/src/replay.js +0 -245
- package/src/reporter-functions.js +0 -55
- package/src/reporter.cjs_decprecated +0 -21
- package/src/reporter.js +0 -33
- package/src/services/artifacts.js +0 -59
- package/src/services/index.js +0 -13
- package/src/services/key-values.js +0 -59
- package/src/services/logger.js +0 -315
- package/src/template/emptyData.svg +0 -23
- package/src/template/testomatio.hbs +0 -1081
- package/src/uploader.js +0 -376
- package/src/utils/pipe_utils.js +0 -119
- package/src/utils/utils.js +0 -416
- package/src/xmlReader.js +0 -614
|
@@ -1,223 +1,255 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
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");
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { v4: uuidv4 } = require('uuid');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const { APP_PREFIX, STATUS: Status, TESTOMAT_TMP_STORAGE_DIR } = require('../constants');
|
|
8
|
+
const TestomatioClient = require('../client');
|
|
9
|
+
const { getTestomatIdFromTestTitle, fileSystem } = require('../utils/utils');
|
|
10
|
+
// const debug = require('debug')('@testomatio/reporter:adapter:playwright');
|
|
11
|
+
const { services } = require('../services');
|
|
12
|
+
const { dataStorage } = require('../data-storage');
|
|
13
|
+
|
|
17
14
|
const reportTestPromises = [];
|
|
15
|
+
|
|
18
16
|
class PlaywrightReporter {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
constructor(config = {}) {
|
|
18
|
+
this.client = new TestomatioClient({ apiKey: config?.apiKey });
|
|
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
|
+
}
|
|
22
50
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.suite = suite;
|
|
29
|
-
this.config = config;
|
|
30
|
-
this.client.createRun();
|
|
51
|
+
|
|
52
|
+
const fullTestTitle = getTestContextName(test);
|
|
53
|
+
let logs = '';
|
|
54
|
+
if (result.stderr.length || result.stdout.length) {
|
|
55
|
+
logs = `\n\n${chalk.bold('Logs:')}\n${chalk.red(result.stderr.join(''))}\n${result.stdout.join('')}`;
|
|
31
56
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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);
|
|
57
|
+
const manuallyAttachedArtifacts = services.artifacts.get(fullTestTitle);
|
|
58
|
+
const testMeta = services.keyValues.get(fullTestTitle);
|
|
59
|
+
const rid = test.id || test.testId || uuidv4();
|
|
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);
|
|
117
116
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (extension)
|
|
128
|
-
filePath += `.${extension}`;
|
|
129
|
-
fs_1.default.writeFileSync(filePath, artifact.body);
|
|
130
|
-
return filePath;
|
|
131
|
-
}
|
|
132
|
-
return null;
|
|
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;
|
|
133
126
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
await Promise.all(promises);
|
|
127
|
+
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async onEnd(result) {
|
|
132
|
+
if (!this.client) return;
|
|
133
|
+
|
|
134
|
+
await Promise.all(reportTestPromises);
|
|
135
|
+
|
|
136
|
+
if (this.uploads.length) {
|
|
137
|
+
if (this.client.uploader.isEnabled) console.log(APP_PREFIX, `🎞️ Uploading ${this.uploads.length} files...`);
|
|
138
|
+
|
|
139
|
+
const promises = [];
|
|
140
|
+
|
|
141
|
+
// ? possible move to addTestRun (needs investigation if files are ready)
|
|
142
|
+
for (const upload of this.uploads) {
|
|
143
|
+
const { rid, file, title } = upload;
|
|
144
|
+
|
|
145
|
+
const files = upload.files.map(attachment => ({
|
|
146
|
+
path: this.#getArtifactPath(attachment),
|
|
147
|
+
title,
|
|
148
|
+
type: attachment.contentType,
|
|
149
|
+
}));
|
|
150
|
+
|
|
151
|
+
if (!this.client.uploader.isEnabled) {
|
|
152
|
+
files.forEach(f => this.client.uploader.storeUploadedFile(f, this.client.runId, rid, false));
|
|
153
|
+
continue;
|
|
162
154
|
}
|
|
163
|
-
|
|
155
|
+
|
|
156
|
+
promises.push(
|
|
157
|
+
this.client.addTestRun(undefined, {
|
|
158
|
+
rid,
|
|
159
|
+
title,
|
|
160
|
+
files,
|
|
161
|
+
file,
|
|
162
|
+
}),
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
await Promise.all(promises);
|
|
164
166
|
}
|
|
167
|
+
|
|
168
|
+
await this.client.updateRunStatus(checkStatus(result.status));
|
|
169
|
+
}
|
|
165
170
|
}
|
|
171
|
+
|
|
166
172
|
function checkStatus(status) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
return (
|
|
174
|
+
{
|
|
175
|
+
skipped: Status.SKIPPED,
|
|
176
|
+
timedOut: Status.FAILED,
|
|
177
|
+
passed: Status.PASSED,
|
|
178
|
+
}[status] || Status.FAILED
|
|
179
|
+
);
|
|
172
180
|
}
|
|
181
|
+
|
|
173
182
|
function appendStep(step, shift = 0) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
183
|
+
// nesting too deep, ignore those steps
|
|
184
|
+
if (shift >= 10) return;
|
|
185
|
+
|
|
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
|
+
|
|
200
|
+
const formattedSteps = [];
|
|
201
|
+
for (const child of step.steps || []) {
|
|
202
|
+
const appendedChild = appendStep(child, shift + 2);
|
|
203
|
+
if (appendedChild) {
|
|
204
|
+
formattedSteps.push(appendedChild);
|
|
196
205
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const resultStep = {
|
|
209
|
+
category: newCategory,
|
|
210
|
+
title: step.title,
|
|
211
|
+
duration: step.duration,
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
if (formattedSteps.length) {
|
|
215
|
+
resultStep.steps = formattedSteps.filter(s => !!s);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (step.error !== undefined) {
|
|
219
|
+
resultStep.error = step.error;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return resultStep;
|
|
209
223
|
}
|
|
224
|
+
|
|
210
225
|
function generateTmpFilepath(filename = '') {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
226
|
+
filename = filename || `tmp.${crypto.randomBytes(16).toString('hex')}`;
|
|
227
|
+
const tmpdir = os.tmpdir();
|
|
228
|
+
return path.join(tmpdir, filename);
|
|
214
229
|
}
|
|
230
|
+
|
|
215
231
|
/**
|
|
216
232
|
* Returns filename + test title
|
|
217
233
|
* @param {*} test - testInfo object from Playwright
|
|
218
234
|
* @returns
|
|
219
235
|
*/
|
|
220
236
|
function getTestContextName(test) {
|
|
221
|
-
|
|
237
|
+
return `${test._requireFile || ''}_${test.title}`;
|
|
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
|
+
}
|
|
222
252
|
}
|
|
253
|
+
|
|
223
254
|
module.exports = PlaywrightReporter;
|
|
255
|
+
module.exports.initPlaywrightForStorage = initPlaywrightForStorage;
|