Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/internal/test_runner/reporter/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const {
ArrayPrototypePush,
ArrayPrototypeShift,
ArrayPrototypeUnshift,
Date,
DatePrototypeToLocaleString,
} = primordials;
const assert = require('assert');
const Transform = require('internal/streams/transform');
Expand Down Expand Up @@ -106,6 +108,9 @@ class SpecReporter extends Transform {
if (data.file === undefined) {
return this.#formatFailedTestResults();
}
break;
case 'test:watch:restarted':
return `\nRestarted at ${DatePrototypeToLocaleString(new Date())}\n`;
}
}
_transform({ type, data }, encoding, callback) {
Expand Down
18 changes: 18 additions & 0 deletions test/test-runner/test-output-spec-reporter-watch-restart.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import '../common/index.mjs';
import { spec as SpecReporter } from 'node:test/reporters';
import assert from 'node:assert';

const reporter = new SpecReporter();
let output = '';

reporter.on('data', (chunk) => {
output += chunk;
});

reporter.write({
type: 'test:watch:restarted',
});

reporter.end();

assert.match(output, /Restarted at .+/);
Loading