@testomatio/reporter 1.0.0-beta.1 → 1.0.0-beta.3
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 +20 -8
- package/lib/client.js +10 -3
- package/lib/fileUploader.js +1 -1
- package/lib/pipe/testomatio.js +3 -2
- package/package.json +1 -1
package/lib/adapter/codecept.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const debug = require('debug')('@testomatio/reporter:adapter:codeceptjs');
|
|
1
2
|
const chalk = require('chalk');
|
|
2
3
|
const TestomatClient = require('../client');
|
|
3
4
|
const { STATUS, APP_PREFIX } = require('../constants');
|
|
@@ -32,6 +33,8 @@ if (MAJOR_VERSION < 3) {
|
|
|
32
33
|
function CodeceptReporter(config) {
|
|
33
34
|
let failedTests = [];
|
|
34
35
|
let videos = [];
|
|
36
|
+
const reportTestPromises = [];
|
|
37
|
+
|
|
35
38
|
const testTimeMap = {};
|
|
36
39
|
const { apiKey } = config;
|
|
37
40
|
|
|
@@ -67,6 +70,9 @@ function CodeceptReporter(config) {
|
|
|
67
70
|
});
|
|
68
71
|
|
|
69
72
|
event.dispatcher.on(event.all.result, async () => {
|
|
73
|
+
// all tests were reported and we can upload videos
|
|
74
|
+
await Promise.all(reportTestPromises);
|
|
75
|
+
|
|
70
76
|
if (videos.length && upload.isArtifactsEnabled()) {
|
|
71
77
|
console.log(APP_PREFIX, `🎞️ Uploading ${videos.length} videos...`);
|
|
72
78
|
|
|
@@ -137,7 +143,7 @@ function CodeceptReporter(config) {
|
|
|
137
143
|
if (test.err) error = test.err;
|
|
138
144
|
const { id, tags, title, artifacts } = test;
|
|
139
145
|
failedTests.push(id || title);
|
|
140
|
-
|
|
146
|
+
let testId = parseTest(tags);
|
|
141
147
|
const testObj = getTestAndMessage(title);
|
|
142
148
|
if (error && error.stack && test.steps && test.steps.length) {
|
|
143
149
|
error.stack = test.steps[test.steps.length - 1].line();
|
|
@@ -145,14 +151,10 @@ function CodeceptReporter(config) {
|
|
|
145
151
|
|
|
146
152
|
const files = [];
|
|
147
153
|
if (artifacts.screenshot) files.push({ path: artifacts.screenshot, type: 'image/png' });
|
|
148
|
-
// todo: video must be uploaded later....
|
|
149
|
-
|
|
150
|
-
for (const aid in artifacts) {
|
|
151
|
-
if (aid.startsWith('video')) videos.push({ testId: id, title, path: artifacts[aid], type: 'video/webm' });
|
|
152
|
-
if (aid.startsWith('trace')) files.push({ testId: id, title, path: artifacts[aid], type: 'application/zip' });
|
|
153
|
-
}
|
|
154
|
+
// todo: video must be uploaded later....
|
|
154
155
|
|
|
155
|
-
|
|
156
|
+
|
|
157
|
+
const reportTestPromise = client.addTestRun(STATUS.FAILED, {
|
|
156
158
|
...stripExampleFromTitle(title),
|
|
157
159
|
test_id: testId,
|
|
158
160
|
suite_title: test.parent && test.parent.title,
|
|
@@ -161,7 +163,17 @@ function CodeceptReporter(config) {
|
|
|
161
163
|
time: getDuration(test),
|
|
162
164
|
files,
|
|
163
165
|
steps: output.text(),
|
|
166
|
+
}).then(pipes => {
|
|
167
|
+
testId = pipes.filter(p => p.pipe.includes('Testomatio'))[0]?.result?.data?.test_id;
|
|
168
|
+
|
|
169
|
+
for (const aid in artifacts) {
|
|
170
|
+
if (aid.startsWith('video')) videos.push({ testId, title, path: artifacts[aid], type: 'video/webm' });
|
|
171
|
+
if (aid.startsWith('trace')) files.push({ testId, title, path: artifacts[aid], type: 'application/zip' });
|
|
172
|
+
}
|
|
164
173
|
});
|
|
174
|
+
|
|
175
|
+
reportTestPromises.push(reportTestPromise);
|
|
176
|
+
|
|
165
177
|
output.stop();
|
|
166
178
|
});
|
|
167
179
|
|
package/lib/client.js
CHANGED
|
@@ -142,9 +142,16 @@ class Client {
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
this.queue = this.queue
|
|
145
|
-
.then(() => Promise.all(this.pipes.map(p =>
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
.then(() => Promise.all(this.pipes.map(async p => {
|
|
146
|
+
try {
|
|
147
|
+
const result = await p.addTest(data);
|
|
148
|
+
return { pipe: p.toString(), result };
|
|
149
|
+
} catch (err) {
|
|
150
|
+
console.log(APP_PREFIX, pipe.toString(), err);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
)));
|
|
154
|
+
|
|
148
155
|
return this.queue;
|
|
149
156
|
}
|
|
150
157
|
|
package/lib/fileUploader.js
CHANGED
|
@@ -220,6 +220,6 @@ const uploadFileAsBuffer = async (buffer, fileName, runId) => {
|
|
|
220
220
|
module.exports = {
|
|
221
221
|
uploadFileByPath: memoize(uploadFileByPath),
|
|
222
222
|
uploadFileAsBuffer: memoize(uploadFileAsBuffer),
|
|
223
|
-
isArtifactsEnabled
|
|
223
|
+
isArtifactsEnabled,
|
|
224
224
|
resetConfig,
|
|
225
225
|
};
|
package/lib/pipe/testomatio.js
CHANGED
|
@@ -169,15 +169,16 @@ class TestomatioPipe {
|
|
|
169
169
|
|
|
170
170
|
module.exports = TestomatioPipe;
|
|
171
171
|
|
|
172
|
-
function setS3Credentials(artifacts) {
|
|
172
|
+
function setS3Credentials(artifacts) {
|
|
173
173
|
if (!Object.keys(artifacts).length) return;
|
|
174
174
|
|
|
175
|
-
console.log(APP_PREFIX, '
|
|
175
|
+
console.log(APP_PREFIX, 'S3 were credentials obtained from Testomat.io...');
|
|
176
176
|
|
|
177
177
|
if (artifacts.ACCESS_KEY_ID) process.env.S3_ACCESS_KEY_ID = artifacts.ACCESS_KEY_ID;
|
|
178
178
|
if (artifacts.SECRET_ACCESS_KEY) process.env.S3_SECRET_ACCESS_KEY = artifacts.SECRET_ACCESS_KEY;
|
|
179
179
|
if (artifacts.REGION) process.env.S3_REGION = artifacts.REGION;
|
|
180
180
|
if (artifacts.BUCKET) process.env.S3_BUCKET = artifacts.BUCKET;
|
|
181
181
|
if (artifacts.ENDPOINT) process.env.S3_ENDPOINT = artifacts.ENDPOINT;
|
|
182
|
+
if (artifacts.presign) process.env.TESTOMATIO_PRIVATE_ARTIFACTS = '1';
|
|
182
183
|
resetConfig();
|
|
183
184
|
}
|