diff --git a/test/known_issues/test-debugger-restart-message.js b/test/known_issues/test-debugger-restart-message.js new file mode 100644 index 00000000000000..b2001c087a3af2 --- /dev/null +++ b/test/known_issues/test-debugger-restart-message.js @@ -0,0 +1,45 @@ +'use strict'; + +// Refs: https://github.com/nodejs/node/issues/39272 + +require('../common'); + +// Will need to uncomment this (and assign `common` above) when moved out of +// known_issues common.skipIfInspectorDisabled(); + +// This can be reduced to 2 or even 1 (and the loop removed) once the debugger +// is fixed. It's set to 32 just to make sure that the error is tripped reliably +// in CI. +const RESTARTS = 32; + +const fixtures = require('../common/fixtures'); +const startCLI = require('../common/debugger'); + +const assert = require('assert'); + +// Using `restart` should result in only one "Connect/For help" message. +{ + const script = fixtures.path('debugger', 'three-lines.js'); + const cli = startCLI([script]); + + function onFatal(error) { + cli.quit(); + throw error; + } + + const listeningRegExp = /Debugger listening on/g; + + cli.waitForInitialBreak() + .then(() => cli.waitForPrompt()) + .then(() => { + assert.strictEqual(cli.output.match(listeningRegExp).length, 1); + }) + .then(async () => { + for (let i = 0; i < RESTARTS; i++) { + await cli.stepCommand('restart'); + assert.strictEqual(cli.output.match(listeningRegExp).length, 1); + } + }) + .then(() => cli.quit()) + .then(null, onFatal); +}