avajs/ava

The Debugging with WebStorm recipe needs updating for the new debug command

novemberborn opened this issue ยท 11 comments

As of #2316, the upcoming v3 release has a built-in debug command. I've updated two of the existing debugging recipes but I'm not a WebStorm user, so this recipe still needs updating: https://github.com/avajs/ava/blob/master/docs/recipes/debugging-with-webstorm.md

@novemberborn Hi!
Is this issue related #1787 ?
I have been failing debugger after upgraded ava to version 3.
But I found how to do debug on WebStorm.
I using

  • WebStorm 2019.3.4
  • AVA 3.5.0

You will be able to do debug mode by this capture.
image

I didn't use npm Configuration but Node.js Configuration.
You do not need to debug mode on ava. Only specify path to test file and click debug button.

ATTENTION:

@erikkemperman said this at #1787. I think so too.

JetBrains are now doing some internal cleverness around debug ports

Is this issue related #1787 ?

No, that issue predates AVA 3.

  • WebStorm will run 2 Debugger Listener (I don't know that reason...)

AVA runs your test file in a child process. You don't need to debug AVA itself.

  • ava have been killed process 10 seconds from v3. Because I didn't run ava's debug mode

Yup. Ideally we can make this work using ava debug.

I've made this plugin.
It also has the timeout issue though, not sure how to fix that.

It also has the timeout issue though, not sure how to fix that.

You'd have to set it to a high value, perhaps using the CLI, eg --timeout=1h.

The approach for VSCode is to configure the port, combined with --break which is somehow needed as well.

Would that work for WebStorm?

@novemberborn Not sure how to fix that in the plugin. I don't do debugging, I let IntelliJ (and friends) handle that. I create a generic nodejs run configuration, and this supports both run and debug out of the box. Perhaps I can specify additional flags when run in debug, need to look that up.

This configuration works perfectly for me using Webstorm 2020.1.

For anyone coming across this issue having trouble using this configuration to debug typescript files, you need to add "sourceMap": true to your tsconfig.json file.

I also want to add that you can set up Webstorm to compile typescript whenever this configuration is run, by adding it as an entry in the "Before launch" section.

Skjermbilde 2020-05-18 kl  14 24 26

@chdefrene would you be interested in doing a PR to add this to the recipe?

hi. since AVA 3 we also have issues with debugging tests with Intellij IDEA - configuration should be similar to that for webstorm but above fix did not help because error is different:

Starting inspector on 127.0.0.1:54264 failed: address already in use

tried to apply the solution used in VisualStudio Code, setting port but with no success. any hints?

This PR may contain a clue as to what needs updating: #2571

These runtime configurations work in Webstorm with and without the debugger. They assume the package.json and node_modules directory are located at the root of the project. TypeScript support can be enabled by following the TypeScript recipe. If these prove helpful to others, I'm happy to help move it into a PR.

NodeJS configuration

  1. Select the NodeJS Configuration type
  2. Add --break to the application parameters
  3. Set the path to the javascript file to the location of the ava test runner ($PROJECT_DIR$/node_modules/.bin/ava)
<!-- .run/Test.run.xml -->
<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="Test" type="NodeJSConfigurationType" application-parameters="--break" path-to-js-file="$PROJECT_DIR$/node_modules/.bin/ava" working-dir="$PROJECT_DIR$">
    <method v="2" />
  </configuration>
</component>

NPM Configuration

  1. Select the NPM Configuration type
  2. Select the test script
  3. Add -- --break to the application parameters
// abbreviated package.json
{
  "scripts": {
    "test": "ava"
  }
}
<!-- .run/Test.run.xml -->
<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="Test" type="js.build_tools.npm">
    <package-json value="$PROJECT_DIR$/package.json" />
    <command value="run" />
    <scripts>
      <script value="test" />
    </scripts>
    <arguments value="-- --break" />
    <node-interpreter value="project" />
    <envs />
    <method v="2" />
  </configuration>
</component>

@stuft2 a PR would be most welcome!