Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. # Debugging with Jest and VSCode
  2.  
  3. ## Assumptions
  4.  
  5. * Your jest config is named `jest.json`.
  6. * You use `babel`.
  7. * You build to `build`.
  8.  
  9. ## Debugging
  10.  
  11. Add the following code as a debugging configuration.
  12.  
  13. ```json
  14. {
  15. "version": "0.2.0",
  16. "configurations": [
  17. {
  18. "name": "Tests",
  19. "type": "node",
  20. "request": "launch",
  21. "program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js",
  22. "stopOnEntry": false,
  23. "args": [
  24. "--config",
  25. "jest.json",
  26. "--runInBand"
  27. ],
  28. "cwd": "${workspaceRoot}",
  29. "preLaunchTask": null,
  30. "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/babel-node",
  31. "runtimeArgs": [
  32. "--nolazy"
  33. ],
  34. "env": {
  35. "NODE_ENV": "development"
  36. },
  37. "console": "internalConsole",
  38. "sourceMaps": true,
  39. "outFiles": [
  40. "${workspaceRoot}/build/**/*.js"
  41. ]
  42. }
  43. ]
  44. }
  45. ```
  46.  
  47. Make sure the following lines are in your `.babelrc`.
  48.  
  49. ```json
  50. ...
  51. "sourceMaps": "inline",
  52. "retainLines": true,
  53. ...
  54. ```
  55.  
  56. Set a breakpoint and debug!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement