@reporters/gh 1.3.0 → 1.4.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.
Files changed (2) hide show
  1. package/index.js +34 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -245,11 +245,45 @@ class SpecReporter extends Transform {
245
245
  return this.#formatFailedTestResults();
246
246
  }
247
247
  break;
248
+ /* c8 ignore next 2 */
249
+ case 'test:interrupted':
250
+ return this.#formatInterruptedTests(data.tests) + res;
248
251
  default:
249
252
  }
250
253
  return ''; // No output for other event types
251
254
  }
252
255
 
256
+ /* c8 ignore start */
257
+ #formatInterruptedTests(tests) {
258
+ if (tests.length === 0) {
259
+ return '';
260
+ }
261
+
262
+ const results = [];
263
+
264
+ if (this.#reportedGroup) {
265
+ results.push(endGroup);
266
+ this.#reportedGroup = false;
267
+ }
268
+
269
+ results.push(
270
+ `\n${styleText('yellow', 'Interrupted while running:', { validateStream: !this.#isGitHubActions })}\n`,
271
+ );
272
+
273
+ for (let i = 0; i < tests.length; i += 1) {
274
+ const test = tests[i];
275
+ let msg = `${indent(test.nesting)}${reporterUnicodeSymbolMap['warning:alert']}${test.name}`;
276
+ if (test.file) {
277
+ const relPath = relative(this.#cwd, test.file);
278
+ msg += ` ${styleText('gray', `(${relPath}:${test.line}:${test.column})`, { validateStream: !this.#isGitHubActions })}`;
279
+ }
280
+ results.push(msg);
281
+ }
282
+
283
+ return `${results.join('\n')}\n`;
284
+ }
285
+ /* c8 ignore stop */
286
+
253
287
  _transform({ type, data }, encoding, callback) {
254
288
  if (type === 'test:coverage' || type === 'test:stderr' || type === 'test:stdout') {
255
289
  /* c8 ignore next 3 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reporters/gh",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "A github actions reporter for `node:test`",
5
5
  "type": "commonjs",
6
6
  "keywords": [