Debugging with TypeScript and Visual Studio Code

351 views
Skip to first unread message

jannnik

unread,
Feb 6, 2018, 11:35:08 AM2/6/18
to NightwatchJs
Is there anybody who got Nightwatch tests running with the vscode debugger in combination with TypeScript? 

I tried lots of different configurations, but always there are the following problems.
  • When stopping at a breakpoint, the debugger jumps directly to the js file instead of the ts file.
  • When adding breakpoints after starting the debugger, the breakpoints jump around in my file and the debugger stops at any other line than the desired line. 
launch.json:
{
 "version": "0.2.0",
 "configurations": [
   {
     "name": "Launch",
     "type": "node",
     "request": "launch",
     "program": "${workspaceRoot}/node_modules/.bin/nightwatch",
     "args": ["--env", "local"],
     "cwd": "${workspaceRoot}",
     "runtimeExecutable": null,
     "runtimeArgs": [],
     "sourceMaps": true,
     "outFiles": ["${workspaceRoot}/build/**/*.js"],
     "diagnosticLogging": true
   }
 ]
}


tsconfig.json
{
"compilerOptions": {
"outDir": "./build",
"module": "esnext",
"target": "es6",
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "./",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true
},
"exclude": ["node_modules", "build", "scripts"]
}


jannnik

unread,
Feb 6, 2018, 11:49:03 AM2/6/18
to NightwatchJs
It looks like I found a solution after reading in this issue: https://github.com/Microsoft/vscode/issues/2472#issuecomment-227595616

After adding  "inlineSourceMap": true to tsconfig.json, debugging works!


Roland

unread,
Sep 23, 2018, 2:27:18 AM9/23/18
to NightwatchJs
Thank you!!
Reply all
Reply to author
Forward
0 new messages