Adding the necessary config in my vscode launch.json file by adding breakpoint to my stepdef and debugging the test throws error and doesn't open up the debugger.
my launch.js file looks like this
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"protocol": "legacy",
"address": "localhost",
"port": 5859,
"timeout": 20000,
"name": "WebdriverIO",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/wdio",
"runtimeArgs": [
"--debug=5859"
],
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/wdio.cmd"
},
"restart": true,
"cwd": "${workspaceRoot}",
"console": "integratedTerminal",
// This args config runs only the file that's open and displayed
// (e.g., a file in test/spec/):
"args":[
"${workspaceRoot}/features/wdio-local.conf.js"
]
}
]
}
i then added the following to the top of my wdio-local.conf.js file
exports.config = {
debug: true,
execArgv: ['--debug=127.0.0.1:5859'],
I then went ahead and added a couple of breakpoints to the step definition that hooks up to my feature file that navigates to a page. in theory, this should when the method 'open' is called.
I am using webdriverio v4 as test needed to be written in cucumber
I got my reference from the following sites:
http://blog.likewise.org/2017/02/debugging-a-javascript-webdriverio-project-in-vscode/
and
https://liesbeek.com/2018/08/03/debug-wdio-vscode/
both don't work.
We run our tests in terminal using npm run command and also pass in a couple of parameters i.e running testing with tags.
NODE_ENV=development T_ENV=staging npm run e2e-test-local -- --cucumberOpts.tagExpression='@404_error'
This all works fine. NOTE we also use a couple of variables.
help required on how to configure the vscode launch.json so that i can debug tests please. many thanks