Skip to content

Commit 03556e5

Browse files
committed
test: add test for debugger restart message issue
Running "restart" in the debugger confusingly prints an out-of-date "Debugger listening on..." message before printing a second updated one. Refs: #39272
1 parent e9cf120 commit 03556e5

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
'use strict';
2+
3+
// Refs: https://github.com/nodejs/node/issues/39272
4+
5+
require('../common');
6+
7+
// Will need to uncomment this (and assign `common` above) when moved out of
8+
// known_issues common.skipIfInspectorDisabled();
9+
10+
// This can be reduced to 2 or even 1 (and the loop removed) once the debugger
11+
// is fixed. It's set to 32 just to make sure that the error is tripped reliably
12+
// in CI.
13+
const RESTARTS = 32;
14+
15+
const fixtures = require('../common/fixtures');
16+
const startCLI = require('../common/debugger');
17+
18+
const assert = require('assert');
19+
20+
// Using `restart` should result in only one "Connect/For help" message.
21+
{
22+
const script = fixtures.path('debugger', 'three-lines.js');
23+
const cli = startCLI([script]);
24+
25+
function onFatal(error) {
26+
cli.quit();
27+
throw error;
28+
}
29+
30+
const listeningRegExp = /Debugger listening on/g;
31+
32+
cli.waitForInitialBreak()
33+
.then(() => cli.waitForPrompt())
34+
.then(() => {
35+
assert.strictEqual(cli.output.match(listeningRegExp).length, 1);
36+
})
37+
.then(async () => {
38+
for (let i = 0; i < RESTARTS; i++) {
39+
await cli.stepCommand('restart');
40+
assert.strictEqual(cli.output.match(listeningRegExp).length, 1);
41+
}
42+
})
43+
.then(() => cli.quit())
44+
.then(null, onFatal);
45+
}

0 commit comments

Comments
 (0)