-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to debug tests? (VS Code) #297
Comments
Im using wallabyjs for that. Its awesome, when you need an immediate info on what your code is doing. And plays well with karma tests. Does it make sense to make a pull-request for a wallabyjs config file? |
I tried it. But that's not what I'm talking about. I'd like to be able to use debugger in VS Code while running tests. So I could set a breakpoint inside test code. |
This extension is usable and allows you to set breakpoints in VS Code, but configuring it correctly is still a pain. Webpack-dev-server puts the transpiled .js files in a virtual filesystem so the sourcemaps can't map the lines correctly to your typescript without some work. Still experimenting. |
Please share your findings when you're done. |
You can get it working by installing the vscode chrome debug extension in vscode (https://github.com/Microsoft/vscode-chrome-debug), and then changing the output in module.exports within webpack.config.js to get webpack to change the sourcemaps to point to the local filesystem.
You'll need to change launch.json in vscode to the following
And finally, you can run npm run build:dev, followed by npm run server:prod to output the build files to dist and get http-server to load from that. Note that you won't be using webpack-dev-server, so you lose the auto-refresh capabilities. You'll have to manually build:dev again whenever you make a code change. |
You could use this plugin: https://github.com/gajus/write-file-webpack-plugin, so you wouldn't need to run two separate scripts to create build files. |
I tried this back when write-file-webpack-plugin had webpack 1.x as a dependency, but I couldn't get it to work. The project now uses webpack 2.x, but things may have improved since the last time I tried. Still requires investigation. |
@siready the write-file-webpack-plugin works smoothly for me as described in #144 (comment) |
Writing tests without being able to debug code is difficult. Can we debug tests somehow in VS Code?
Thanks!
The text was updated successfully, but these errors were encountered: