Skip to content

Commit d749c22

Browse files
authored
Update guide for the .debug() command (#370)
1 parent 611e21c commit d749c22

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

docs/guide/debugging-tests/using-debug.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ description: Learn how to pause your test at specific points and debug by access
99

1010
This is a new command added in Nightwatch v2.3.0, which allows users to pause the test at any point (by using [`.debug()`](/api/debug.html) command as a breakpoint) and use a REPL interface (made available in the terminal) to try out the available Nightwatch commands and assertions and see them get executed against the running browser, in real-time.
1111

12-
While doing that, users can also interact with the browser and use DevTools to debug. The interface also supports multi-line code input and auto-complete feature.
12+
While doing that, users can also interact with the browser and use DevTools to debug. The interface also supports multi-line code input and auto-complete feature. Users can also expose local variables and helper functions from their test to the REPL interface, using the `context` option.
1313

1414
### Usage
1515

1616
**Note:** Please use `async/await` while using the `.debug()` command, otherwise proper results won't be returned back to the interface.
1717

1818
<pre class="language-javascript"><code class="language-javascript">it('demos debug command', async function(browser) {
19+
const someLocalVariable = 'something random';
20+
function someLocalFunction() {
21+
return 'local function result';
22+
}
23+
24+
// with default options
1925
await browser.debug();
2026

2127
// with no auto-complete
@@ -24,6 +30,12 @@ While doing that, users can also interact with the browser and use DevTools to d
2430
// with a timeout of 6000 ms (time for which the interface
2531
// would wait for a result, default is 5500ms).
2632
await browser.debug({timeout: 6000})
33+
34+
// expose local variables/functions to the debug REPL
35+
browser.debug({
36+
// both values below will be directly available in the debug REPL
37+
context: {someLocalVariable, someLocalFunction}
38+
});
2739
});
2840
</code></pre>
2941

0 commit comments

Comments
 (0)