@testomatio/reporter 2.8.6-beta-fix-xml-batch → 2.9.0
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 +19 -0
- package/lib/pipe/coverage.js +18 -6
- package/package.json +1 -1
- package/src/adapter/codecept.js +24 -2
- package/src/pipe/coverage.js +25 -7
package/lib/adapter/codecept.js
CHANGED
|
@@ -43,6 +43,7 @@ if (MAJOR_VERSION === 3 && MINOR_VERSION < 7) {
|
|
|
43
43
|
}
|
|
44
44
|
function CodeceptReporter(config) {
|
|
45
45
|
const failedTests = [];
|
|
46
|
+
const reportedTestUids = new Set();
|
|
46
47
|
let videos = [];
|
|
47
48
|
let traces = [];
|
|
48
49
|
const reportTestPromises = [];
|
|
@@ -141,6 +142,7 @@ function CodeceptReporter(config) {
|
|
|
141
142
|
return;
|
|
142
143
|
const error = hook?.ctx?.currentTest?.err;
|
|
143
144
|
for (const test of suite.tests) {
|
|
145
|
+
reportedTestUids.add(test.uid);
|
|
144
146
|
const reportTestPromise = client.addTestRun('failed', {
|
|
145
147
|
...stripExampleFromTitle(test.title),
|
|
146
148
|
rid: test.uid,
|
|
@@ -171,9 +173,26 @@ function CodeceptReporter(config) {
|
|
|
171
173
|
await finalizeRun('all.after');
|
|
172
174
|
});
|
|
173
175
|
});
|
|
176
|
+
event.dispatcher.on(event.test.skipped, test => {
|
|
177
|
+
const { uid, tags, title } = test.simplify();
|
|
178
|
+
if (uid && reportedTestUids.has(uid))
|
|
179
|
+
return;
|
|
180
|
+
index_js_1.services.setContext(null);
|
|
181
|
+
const reportTestPromise = client.addTestRun(constants_js_1.STATUS.SKIPPED, {
|
|
182
|
+
...stripExampleFromTitle(title),
|
|
183
|
+
rid: uid,
|
|
184
|
+
test_id: (0, utils_js_1.getTestomatIdFromTestTitle)(`${title} ${tags?.join(' ')}`),
|
|
185
|
+
suite_title: test.parent && stripTagsFromTitle(stripExampleFromTitle(test.parent.title).title),
|
|
186
|
+
time: test.duration,
|
|
187
|
+
meta: test.meta,
|
|
188
|
+
});
|
|
189
|
+
reportTestPromises.push(reportTestPromise);
|
|
190
|
+
reportedTestUids.add(uid);
|
|
191
|
+
});
|
|
174
192
|
event.dispatcher.on(event.test.after, test => {
|
|
175
193
|
const { uid, tags, title, artifacts } = test.simplify();
|
|
176
194
|
const error = test.err || null;
|
|
195
|
+
reportedTestUids.add(uid);
|
|
177
196
|
failedTests.push(uid || title);
|
|
178
197
|
const testObj = getTestAndMessage(title);
|
|
179
198
|
const files = buildArtifactFiles(artifacts);
|
package/lib/pipe/coverage.js
CHANGED
|
@@ -221,9 +221,10 @@ class CoveragePipe {
|
|
|
221
221
|
*/
|
|
222
222
|
#getChangedFilesFromGit(cmd) {
|
|
223
223
|
try {
|
|
224
|
+
// Capture stderr (instead of ignoring it) so Git's actual error is available for diagnostics
|
|
224
225
|
const result = (0, child_process_1.execSync)(cmd, {
|
|
225
226
|
encoding: 'utf-8',
|
|
226
|
-
stdio: ['pipe', 'pipe', '
|
|
227
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
227
228
|
});
|
|
228
229
|
return result
|
|
229
230
|
.split('\n')
|
|
@@ -231,15 +232,26 @@ class CoveragePipe {
|
|
|
231
232
|
.filter(Boolean);
|
|
232
233
|
}
|
|
233
234
|
catch (err) {
|
|
234
|
-
|
|
235
|
-
|
|
235
|
+
// Prefer Git's own stderr output, fall back to the generic error message
|
|
236
|
+
const gitOutput = (err.stderr || '').toString().trim();
|
|
237
|
+
const errorMessage = gitOutput || err.message || '';
|
|
238
|
+
// Git edge: Not a git repository
|
|
236
239
|
if (errorMessage.includes('Not a git repository')) {
|
|
237
240
|
log_js_1.log.error('❌ Error: This folder is not a Git repository.');
|
|
241
|
+
return [];
|
|
238
242
|
}
|
|
239
|
-
|
|
240
|
-
|
|
243
|
+
// Git edge: the branch/ref to diff against is not available locally.
|
|
244
|
+
// This is common in CI, where a shallow checkout fetches only the current branch.
|
|
245
|
+
if (errorMessage.includes('unknown revision') ||
|
|
246
|
+
errorMessage.includes('ambiguous argument') ||
|
|
247
|
+
errorMessage.includes('bad revision')) {
|
|
248
|
+
log_js_1.log.error(`❌ Git command failed ("${cmd}"):\n${errorMessage}`);
|
|
249
|
+
log_js_1.log.error(`🔍 Branch "${this.branch}" was not found locally. ` +
|
|
250
|
+
`In CI this usually means a shallow checkout — fetch full history first, e.g. ` +
|
|
251
|
+
`actions/checkout with "fetch-depth: 0", or run "git fetch origin ${this.branch}:${this.branch}".`);
|
|
252
|
+
return [];
|
|
241
253
|
}
|
|
242
|
-
|
|
254
|
+
throw new Error(`❌ Git command failed ("${cmd}"):\n${errorMessage}`);
|
|
243
255
|
}
|
|
244
256
|
}
|
|
245
257
|
/**
|
package/package.json
CHANGED
package/src/adapter/codecept.js
CHANGED
|
@@ -48,6 +48,7 @@ if (MAJOR_VERSION === 3 && MINOR_VERSION < 7) {
|
|
|
48
48
|
|
|
49
49
|
function CodeceptReporter(config) {
|
|
50
50
|
const failedTests = [];
|
|
51
|
+
const reportedTestUids = new Set();
|
|
51
52
|
let videos = [];
|
|
52
53
|
let traces = [];
|
|
53
54
|
const reportTestPromises = [];
|
|
@@ -161,6 +162,7 @@ function CodeceptReporter(config) {
|
|
|
161
162
|
const error = hook?.ctx?.currentTest?.err;
|
|
162
163
|
|
|
163
164
|
for (const test of suite.tests) {
|
|
165
|
+
reportedTestUids.add(test.uid);
|
|
164
166
|
const reportTestPromise = client.addTestRun('failed', {
|
|
165
167
|
...stripExampleFromTitle(test.title),
|
|
166
168
|
rid: test.uid,
|
|
@@ -197,9 +199,29 @@ function CodeceptReporter(config) {
|
|
|
197
199
|
});
|
|
198
200
|
});
|
|
199
201
|
|
|
202
|
+
event.dispatcher.on(event.test.skipped, test => {
|
|
203
|
+
const { uid, tags, title } = test.simplify();
|
|
204
|
+
|
|
205
|
+
if (uid && reportedTestUids.has(uid)) return;
|
|
206
|
+
|
|
207
|
+
services.setContext(null);
|
|
208
|
+
|
|
209
|
+
const reportTestPromise = client.addTestRun(STATUS.SKIPPED, {
|
|
210
|
+
...stripExampleFromTitle(title),
|
|
211
|
+
rid: uid,
|
|
212
|
+
test_id: getTestomatIdFromTestTitle(`${title} ${tags?.join(' ')}`),
|
|
213
|
+
suite_title: test.parent && stripTagsFromTitle(stripExampleFromTitle(test.parent.title).title),
|
|
214
|
+
time: test.duration,
|
|
215
|
+
meta: test.meta,
|
|
216
|
+
});
|
|
217
|
+
reportTestPromises.push(reportTestPromise);
|
|
218
|
+
reportedTestUids.add(uid);
|
|
219
|
+
});
|
|
220
|
+
|
|
200
221
|
event.dispatcher.on(event.test.after, test => {
|
|
201
222
|
const { uid, tags, title, artifacts } = test.simplify();
|
|
202
223
|
const error = test.err || null;
|
|
224
|
+
reportedTestUids.add(uid);
|
|
203
225
|
failedTests.push(uid || title);
|
|
204
226
|
const testObj = getTestAndMessage(title);
|
|
205
227
|
const files = buildArtifactFiles(artifacts);
|
|
@@ -211,8 +233,8 @@ function CodeceptReporter(config) {
|
|
|
211
233
|
|
|
212
234
|
// Build step hierarchy with screenshot from screenshotOnFail
|
|
213
235
|
const stepHierarchy = buildUnifiedStepHierarchy(
|
|
214
|
-
test.steps,
|
|
215
|
-
hookSteps,
|
|
236
|
+
test.steps,
|
|
237
|
+
hookSteps,
|
|
216
238
|
screenshotOnFailPath
|
|
217
239
|
);
|
|
218
240
|
|
package/src/pipe/coverage.js
CHANGED
|
@@ -261,9 +261,10 @@ class CoveragePipe { // or Changes for the future???
|
|
|
261
261
|
*/
|
|
262
262
|
#getChangedFilesFromGit(cmd) {
|
|
263
263
|
try {
|
|
264
|
+
// Capture stderr (instead of ignoring it) so Git's actual error is available for diagnostics
|
|
264
265
|
const result = execSync(cmd, {
|
|
265
266
|
encoding: 'utf-8',
|
|
266
|
-
stdio: ['pipe', 'pipe', '
|
|
267
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
267
268
|
});
|
|
268
269
|
|
|
269
270
|
return result
|
|
@@ -272,16 +273,33 @@ class CoveragePipe { // or Changes for the future???
|
|
|
272
273
|
.filter(Boolean);
|
|
273
274
|
}
|
|
274
275
|
catch (err) {
|
|
275
|
-
|
|
276
|
-
|
|
276
|
+
// Prefer Git's own stderr output, fall back to the generic error message
|
|
277
|
+
const gitOutput = (err.stderr || '').toString().trim();
|
|
278
|
+
const errorMessage = gitOutput || err.message || '';
|
|
279
|
+
|
|
280
|
+
// Git edge: Not a git repository
|
|
277
281
|
if (errorMessage.includes('Not a git repository')) {
|
|
278
|
-
log.error(
|
|
282
|
+
log.error('❌ Error: This folder is not a Git repository.');
|
|
283
|
+
return [];
|
|
279
284
|
}
|
|
280
|
-
|
|
281
|
-
|
|
285
|
+
|
|
286
|
+
// Git edge: the branch/ref to diff against is not available locally.
|
|
287
|
+
// This is common in CI, where a shallow checkout fetches only the current branch.
|
|
288
|
+
if (
|
|
289
|
+
errorMessage.includes('unknown revision') ||
|
|
290
|
+
errorMessage.includes('ambiguous argument') ||
|
|
291
|
+
errorMessage.includes('bad revision')
|
|
292
|
+
) {
|
|
293
|
+
log.error(`❌ Git command failed ("${cmd}"):\n${errorMessage}`);
|
|
294
|
+
log.error(
|
|
295
|
+
`🔍 Branch "${this.branch}" was not found locally. ` +
|
|
296
|
+
`In CI this usually means a shallow checkout — fetch full history first, e.g. ` +
|
|
297
|
+
`actions/checkout with "fetch-depth: 0", or run "git fetch origin ${this.branch}:${this.branch}".`
|
|
298
|
+
);
|
|
299
|
+
return [];
|
|
282
300
|
}
|
|
283
301
|
|
|
284
|
-
|
|
302
|
+
throw new Error(`❌ Git command failed ("${cmd}"):\n${errorMessage}`);
|
|
285
303
|
}
|
|
286
304
|
}
|
|
287
305
|
|