mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
test_runner: print info when test restarts
When using spec reporter and running test in watch mode, print an info message containing the current datetime when tests restart. Fixes: https://github.com/nodejs/node/issues/57206 PR-URL: https://github.com/nodejs/node/pull/61160 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit is contained in:
1 parent
8365edcbd0
commit
a3ddfbe191
2 files changed
+23
No files matched your search
@@ -5,6 +5,8 @@ const {
|
||||
ArrayPrototypePush,
|
||||
ArrayPrototypeShift,
|
||||
ArrayPrototypeUnshift,
|
||||
Date,
|
||||
DatePrototypeToLocaleString,
|
||||
} = primordials;
|
||||
const assert = require('assert');
|
||||
const Transform = require('internal/streams/transform');
|
||||
@@ -101,6 +103,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) {
|
||||
|
||||
@@ -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 .+/);
|
||||
Reference in new issue
Block a user