Create a .vscode/launch.json file containing:
{
"version": "0.0.1",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Nightwatch",
"program": "${workspaceRoot}/node_modules/nightwatch/bin/runner.js",
"stopOnEntry": false,
"args": [
"--test",
"tests/blah.js",
"--env",
"local_dev",
"--retries",
"0",
"--output",
"hello_reports"
],
"runtimeExecutable": null,
"sourceMaps": false
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858
}
]
}
Where the args are the command line arguments you feed in to your Nightwatch test.
This is assuming you've installed the nightwatch npm node_module (which is probably a given if you're running the tests).
Chuck a breakpoint in and you're good to go.
You may want to override the nightwatch.conf.js settings to reduce/alter timeouts also, as who wants to wait 60 seconds in this day and age.
Additionally the --env argument refers to a configuration defined in the nightwatch.conf.js file.
e.g.
test_settings: {
local_dev: {
globals: {
waitForConditionTimeout: 10000,
},
start_process: true,
launch_url: 'http://localhost',
selenium_port: 4444,
selenium_host: 'localhost',
skip_testcases_on_fail: false,
end_session_on_fail: true,
use_xpath: true,
test_workers: {
enabled: true,
workers: 15
},
request_timeout_options: {
timeout: 10000,
retry_attempts: 1
},
screenshots: {
enabled: true,
on_failure: true,
on_error: false,
path: './screenshots'
},
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
args: [
'--start-maximized',
'proxy-server=http://...',
'window-size=1280,1696',
'disable-gpu',
'no-sandbox'
],
prefs: {
'credentials_enable_service': false
}
}
}
},