8

I need to launch a particular .js file for execution, in this way:

  1. npx app.js launch.conf.js //for execution of scripts

  2. npx app.js debug.conf.js //for debugging the scripts

In my debug.conf.js contains

const config = {
  debug: true,
  execArgv: ['--inspect-brk'],
  maxInstances: 1,
  cucumberOpts: {
    timeout: 30 * 1000 * 4,
  },
};
exports.config =config

, When I Execute the 2nd command via CMD I'm able to debug using chromedev Tools debugger. but when I need to debug using the VS code Editor:this is present in my launch.json file:

"type": "node",
"name": "manager",
"request": "launch",
"protocol": "auto",
//  "port": 5859,
"program": "${workspaceRoot}\\node_modules\\cdem\\bin\\app",
"execArgv": ["--inspect-brk"],
"args": [
    "run wdio.debug.conf.js"
]

I keep getting the console op as: debugger attached, waiting for debugger to disconnect and the execution is not launched.

Can someone let me how to debug this app using VS Code?

Yuki Inoue
  • 3,569
  • 5
  • 34
  • 53
Tony Frost
  • 81
  • 1
  • 2
  • npx expects a module/bin as it's first argument. So, if you have jest installed as a module you can run `npx jest ...`. I don't think `npx app.js` makes sense. – Marc Sep 26 '19 at 14:50
  • Not sure if this one is still actual, WebdriverIO debugging docs were updated and there is an example VSCode config https://webdriver.io/docs/debugging.html#debugging-with-visual-studio-code-vscode Does it resolve your issue? – Mike G. Sep 21 '20 at 14:34

1 Answers1

2

https://webdriver.io/docs/debugging provides details on how to run in VS code (thank you Mike (comment)):

  1. Go to Run and Debug tab/blade (Ctrl + Shift + D)

  2. Create a launch.json file (e.g. type Node.js on environment bar) or click the cog at the top for other options

  3. .vscode/launch.json opens up or locate and open it (from project's root folder)

  4. Paste this in the configurations array, adjust according to your parameters/arguments and save the file:

     {
         "name": "run select spec",
         "type": "node",
         "request": "launch",
         // To run all spec files remove "--spec", "${file}" from below
         "args": ["wdio.conf.js", "--spec", "${file}"],
         "cwd": "${workspaceFolder}",
         "autoAttachChildProcesses": true,
         "program": "${workspaceRoot}/node_modules/@wdio/cli/bin/wdio.js",
         "console": "integratedTerminal",
         "skipFiles": [
             "${workspaceFolder}/node_modules/**/*.js",
             "${workspaceFolder}/lib/**/*.js",
             "<node_internals>/**/*.js"
         ]
     },
    
  5. Run the above by choosing this configuration (e.g. "run select spec") from the top left dropdown/select menu (or press F5 if already selected).

CPHPython
  • 12,379
  • 5
  • 59
  • 71