Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Debugging with Jest and VSCode
- ## Assumptions
- * Your jest config is named `jest.json`.
- * You use `babel`.
- * You build to `build`.
- ## Debugging
- Add the following code as a debugging configuration.
- ```json
- {
- "version": "0.2.0",
- "configurations": [
- {
- "name": "Tests",
- "type": "node",
- "request": "launch",
- "program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js",
- "stopOnEntry": false,
- "args": [
- "--config",
- "jest.json",
- "--runInBand"
- ],
- "cwd": "${workspaceRoot}",
- "preLaunchTask": null,
- "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/babel-node",
- "runtimeArgs": [
- "--nolazy"
- ],
- "env": {
- "NODE_ENV": "development"
- },
- "console": "internalConsole",
- "sourceMaps": true,
- "outFiles": [
- "${workspaceRoot}/build/**/*.js"
- ]
- }
- ]
- }
- ```
- Make sure the following lines are in your `.babelrc`.
- ```json
- ...
- "sourceMaps": "inline",
- "retainLines": true,
- ...
- ```
- Set a breakpoint and debug!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement