Skip to content

Commit 6e1beda

Browse files
Xstoudiaduh95
authored andcommitted
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: #57206 PR-URL: #61160 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parent f5803cc commit 6e1beda

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

‎lib/internal/test_runner/reporter/spec.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const {
55
ArrayPrototypePush,
66
ArrayPrototypeShift,
77
ArrayPrototypeUnshift,
8+
Date,
9+
DatePrototypeToLocaleString,
810
}=primordials;
911
constassert=require('assert');
1012
constTransform=require('internal/streams/transform');
@@ -101,6 +103,9 @@ class SpecReporter extends Transform {
101103
if(data.file===undefined){
102104
returnthis.#formatFailedTestResults();
103105
}
106+
break;
107+
case'test:watch:restarted':
108+
return`\nRestarted at ${DatePrototypeToLocaleString(newDate())}\n`;
104109
}
105110
}
106111
_transform({ type, data },encoding,callback){
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import'../common/index.mjs';
2+
import{specasSpecReporter}from'node:test/reporters';
3+
importassertfrom'node:assert';
4+
5+
constreporter=newSpecReporter();
6+
letoutput='';
7+
8+
reporter.on('data',(chunk)=>{
9+
output+=chunk;
10+
});
11+
12+
reporter.write({
13+
type: 'test:watch:restarted',
14+
});
15+
16+
reporter.end();
17+
18+
assert.match(output,/Restartedat.+/);

0 commit comments

Comments
 (0)