4

I have some jest tests for my application. Other js sources which are used by the tests are written in js ES6 with Flow. My goal is to debug the sources used by tests. When I debug them, however, the code is in transpiled/minified form.

I tried the following:

  • ./node_modules/.bin/babel-node debug ./node_modules/.bin/jest --runInBand but the files are still minified (I have .babelrc with es2015 and stage-3 presets)
  • ./node_modules/.bin/babel-node --debug ./node_modules/jest-cli/bin/jest.js --runInBand but it hangs after launching jest
  • babel-node-debug sources displayed correctly but terminates before debugging (error described here)
  • babel-node with presets on the command line but it thought presets were modules (Error: Cannot find module *path*/es2015,stage-3, similar error with space between them)
  • node-inspector with babel-node debug. Shows sources correctly but it won't let me debug (the same error as above).
  • ./node_modules/.bin/babel-node ./node_modules/bugger/bin/bugger.js -b ./node_modules/jest-cli/bin/jest.js --runInBand (using bugger and babel-node - hangs after launching jest

My assumption

babel-node does generate appropriate source maps but command line debugger cannot read them and GUI tools somehow don't work. How to verify it?

My environment:

Node v6.0.0 jest v12.0.2 (dev dependency) babel 5.8.38 (babel-core 5.8.38) (dev dependency)

Desired results

I would ultimately like to debug my files in chrome dev tools, but I wouldn't complain about the command line debugger.

I'm hesitant about installing yet more magic tools I don't know how to use, but I would be delighted to know why if I have to.


I'm new to the whole js stack so forgive me my silly questions!

wczekalski
  • 720
  • 4
  • 21
  • Have you tried enabling source maps in babel (or the tool launching it)? Those work pretty well with recent version of the Chrome debugger, including resolving variable names. – ssube May 09 '16 at 14:34
  • @ssube how do I do that? – wczekalski May 09 '16 at 14:36
  • You should specify `sourceMaps` in your `.babelrc`. I would suggest setting them to `inline` for simplicity. – ssube May 09 '16 at 14:38
  • I did set it now, but I still cannot launch a UI debugger. Is my assumption about command line debugger correct? – wczekalski May 09 '16 at 14:50
  • yes, atm cli debugger does not make use of sourcemaps. Yo can try to connect chrome directly, I thisnk as of version v6.3.0 node can understand CRD protocol in addition to V8 debugger protocol - see https://nodejs.org/api/debugger.html#debugger_v8_inspector_integration_for_node_js – Andrey Sidorov Sep 22 '16 at 06:32

0 Answers0