Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc,test: add information on unwatch(index) command #42882

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/api/debugger.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ debug>
after)
* `watch(expr)`: Add expression to watch list
* `unwatch(expr)`: Remove expression from watch list
* `unwatch(index)`: Remove expression at specific index from watch list
* `watchers`: List all watchers and their values (automatically listed on each
breakpoint)
* `repl`: Open debugger's repl for evaluation in debugging script's context
Expand Down
1 change: 1 addition & 0 deletions lib/internal/debugger/inspect_repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ breakOnNone Don't pause on exceptions (this is the default)

watch(expr) Start watching the given expression
unwatch(expr) Stop watching an expression
unwatch(index) Stop watching an expression at specific index from watch list
watchers Print all watched expressions and their current values

exec(expr), p(expr), exec expr, p expr
Expand Down
15 changes: 12 additions & 3 deletions test/sequential/test-debugger-watchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,27 @@ const assert = require('assert');
.then(() => cli.command('watchers'))
.then(() => {
assert.match(cli.output, /x is not defined/);
assert.match(cli.output, /1: "Hello" = 'Hello'/);
assert.match(cli.output, /2: 42 = 42/);
assert.match(cli.output, /3: NaN = NaN/);
assert.match(cli.output, /4: true = true/);
assert.match(cli.output, /5: \[1, 2\] = \[ 1, 2 \]/);
assert.match(
cli.output,
/6: process\.env =\n\s+\{[\s\S]+,\n\s+\.\.\. \}/,
'shows "..." for process.env');
})
.then(() => cli.command('unwatch(4)'))
.then(() => cli.command('unwatch("42")'))
.then(() => cli.stepCommand('n'))
.then(() => {
assert.match(cli.output, /0: x = 10/);
assert.match(cli.output, /1: "Hello" = 'Hello'/);
assert.match(cli.output, /2: NaN = NaN/);
assert.match(cli.output, /3: true = true/);
assert.match(cli.output, /4: \[1, 2\] = \[ 1, 2 \]/);
assert.match(cli.output, /3: \[1, 2\] = \[ 1, 2 \]/);
assert.match(
cli.output,
/5: process\.env =\n\s+\{[\s\S]+,\n\s+\.\.\. \}/,
/4: process\.env =\n\s+\{[\s\S]+,\n\s+\.\.\. \}/,
'shows "..." for process.env');
})
.then(() => cli.quit())
Expand Down