From 9cd79133f74339ba93fcf7c9229c061aefbb7a77 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 28 Jul 2021 20:56:11 -0700 Subject: [PATCH] test: add test-debugger-breakpint-exists In Node.js 15, calling `setBreakpoint(1)` and `restart` twice in a row caused the debugger to exit. In Node.js 16, it no longer exits but throws an error that is expected, or at least reasonable, or at least better than exiting. The error message previously had `undefined` appended to it. It no longer does. This adds test coverage to `unpackError()` in `lib/internal/debugger/inspect_client.js`. That function previously was untested. Refs: https://github.com/nodejs/node-inspect/issues/101 --- .../test-debugger-breakpoint-exists.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/sequential/test-debugger-breakpoint-exists.js diff --git a/test/sequential/test-debugger-breakpoint-exists.js b/test/sequential/test-debugger-breakpoint-exists.js new file mode 100644 index 00000000000000..bceb23000561a8 --- /dev/null +++ b/test/sequential/test-debugger-breakpoint-exists.js @@ -0,0 +1,31 @@ +'use strict'; + +const common = require('../common'); + +common.skipIfInspectorDisabled(); + +const fixtures = require('../common/fixtures'); +const startCLI = require('../common/debugger'); + +// Test for "Breakpoint at specified location already exists" error. +{ + const script = fixtures.path('debugger', 'three-lines.js'); + const cli = startCLI([script]); + + function onFatal(error) { + cli.quit(); + throw error; + } + + cli.waitForInitialBreak() + .then(() => cli.waitForPrompt()) + .then(() => cli.command('setBreakpoint(1)')) + .then(() => cli.command('restart')) + .then(() => cli.waitForInitialBreak()) + .then(() => cli.waitForPrompt()) + .then(() => cli.command('setBreakpoint(1)')) + .then(() => cli.command('restart')) + .then(() => cli.waitFor(/Breakpoint at specified location already exists/)) + .then(() => cli.quit()) + .then(null, onFatal); +}