Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
novemberborn opened this issue Dec 23, 2019 · 11 comments

Comments

@novemberborn
Copy link
Member

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

@hikyaru-suzuki
Copy link

@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

@novemberborn
Copy link
Member Author

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.

@eirikb
Copy link

eirikb commented Mar 19, 2020

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

@novemberborn
Copy link
Member Author

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?

@eirikb
Copy link

eirikb commented Mar 21, 2020

@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.

@chdefrene
Copy link

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

@novemberborn
Copy link
Member Author

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

@dvddpl
Copy link

dvddpl commented Jun 2, 2020

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?

@novemberborn
Copy link
Member Author

novemberborn commented Sep 27, 2020

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

@stuft2
Copy link

stuft2 commented Dec 17, 2022

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>

@novemberborn
Copy link
Member Author

@stuft2 a PR would be most welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
@novemberborn @eirikb @chdefrene @dvddpl @stuft2 @hikyaru-suzuki and others