简体   繁体   中英

JavaScript: How to use WebStorm debugger with ava

This is not question, just answer:

  1. Create run/debug configuration, type Node.js
  2. Select your node interpreter
  3. As node parameter insert your ava bin and parameter --verbose

    For me it's: ./node_modules/.bin/ava --verbose

  4. Select your working directory
  5. Done, now you can debug

The magic is in --verbose , I have no idea why it works that way, but it does.

WebStorm 截图

I have no idea why/how it works for you - configuration is definitely wrong. With your configuration, --inspect-brk is passed to ava, not to Node.js, and thus treated as your application argument. You should have specified node_modules/.bin/ava as JavaScript file: in your Run configuration instead of specifying it as a Node parameter, to make sure that Node debug arguments are passed before the application main file. --verbose can be passed as application parameter.

See also https://github.com/avajs/ava/blob/master/docs/recipes/debugging-with-webstorm.md

Ava is a lightweight test runner for javascript, because there is not a clear answer on how to run ava tests via webstorm and I've been searching for this a while now, I'm sharing my ava WebStorm config.

Create a new node test runner with following configuration:

Node interpreter : whatever version of node that you are using that is compatible with your ava version

Working directory : ~/Documents/Work/projectRootDir

Javascript file : node_modules/ava/cli.js

Application parameters : -v outdir/testFile eg /dist/test/controllers/test.js 示例imageofconfig

There you go, now you can run and debug AVA with the best javascript IDE instead of console logging! I'm quite sure that vscode config will be quite similar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM