0

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 screenshot

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • Actualy I'have idea why it works, it may be because with verbose, webstorm have enough time, or needed outputs to attach debugger to all "sessions" – Richard Bureš Mar 12 '18 at 22:36
  • Please specify what exactly you are asking.. are you asking why `--verbose` works the way it does? – Smokey Dawson Mar 12 '18 at 22:45
  • 1
    If you want to provide some useful answer for others (for a problem that you have faced) ... better make a proper question and then answer it yourself. DO NOT create *"This is not question, just answer"* stuff – LazyOne Mar 13 '18 at 11:20

2 Answers2

0

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 e.g. /dist/test/controllers/test.jsexampleimageofconfig

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

Kelvijn
  • 179
  • 4
  • 17
  • 1
    `cli.js` seems to have moved to `node_modules/ava/entrypoints/cli.mjs`. With that configuration, running the test works, but debugging does not (execution seems to hang at the very beginning, and no tests are run). Node 18.7.1, Ava 5.3.1, WebStorm 2023.2.1, which has just celebrated [7 years of requests for Ava support](https://youtrack.jetbrains.com/issue/WEB-21788)! – Dan Dascalescu Aug 30 '23 at 04:32
-1

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

lena
  • 90,154
  • 11
  • 145
  • 150
  • The [recipe at that link](https://github.com/avajs/ava/blob/master/docs/recipes/debugging-with-webstorm.md) is marked outdated and indeed doens't work. – Dan Dascalescu Aug 30 '23 at 04:25