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

Jest - Debug usage with WebStorm #5

Open
Vadorequest opened this issue Jul 25, 2019 · 9 comments
Open

Jest - Debug usage with WebStorm #5

Vadorequest opened this issue Jul 25, 2019 · 9 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@Vadorequest
Copy link

Webstorm natively supports debugging tests (single test, multiple tests, whole file) with jest. But since this plugin requires to invoke tests using serverless-bundle script, it's somewhat incompatible with WebStorm's native way of running tests and results with "Jest encountered an unexpected token" because it can't understand ES6 import/export (it's not running jest through webpack/babel)

What's the recommended way to configure WebStorm with serverless-bundle? Or is there any known workaround? (I believe it's possible to configure webstorm to run tests through serverless-bundle, but haven't figured out how yet)

image

image

@jayair
Copy link
Member

jayair commented Jul 25, 2019

Oh that's interesting. We use a similar approach to Create React App. Do you have any experience with using WebStorm with Create React App?

@jayair jayair added the question Further information is requested label Jul 25, 2019
@Vadorequest
Copy link
Author

I don't, but looking at my code I see I use react-app-rewired, which does also something quite similar, see:

@jayair
Copy link
Member

jayair commented Jul 26, 2019

If they are doing something similar then it might be related to this issue - #4. Maybe all the arguments are not being passed in.

Once we fix that, let's give this a try again.

@patrykkrawczyk
Copy link
Contributor

any progress on this? running tests with serverless-bundle test in terminal seems medieval

@jayair
Copy link
Member

jayair commented Jan 2, 2020

@patrykkrawczyk Not right now. I'm not a WebStorm user, so I need some help with this.

@jayair jayair added the help wanted Extra attention is needed label Jan 2, 2020
@markisadesignerd
Copy link

markisadesignerd commented Feb 5, 2020

@Vadorequest, @patrykkrawczyk: The way I worked around this was to:

  1. Add jest@24.9.0 as a devDependency to my own project's package.json (optional I think, but otherwise WebStorm wouldn't display the inline test/debug icon in the editor)
  2. Create a jest.config.js file in your project's root that loads the serverless-bundle config:
// jest.config.js
const path = require('path');
const createJestConfig = require('serverless-bundle/scripts/config/createJestConfig');
const relativePath = (relativePath) => path.resolve(__dirname, 'node_modules/serverless-bundle', relativePath);
module.exports = createJestConfig(relativePath, __dirname);
  1. Update your Jest Run/Debug configuration to use the Configuration file from step 2 and the Jest package from serverless-bundle, e.g.: {your-project-root}/node_modules/serverless-bundle/node_modules/jest
    image

That seemed to do the trick for me.

@rmjwilbur
Copy link

Thanks @markisadesignerd - that worked for me in IntelliJ

I had to remove "type": "module" from my package.json but I can live with that. Also I am pointed to my project's node_modules/jest folder.

@jayair
Copy link
Member

jayair commented Feb 8, 2020

@markisadesignerd Thank you for this! I'll link to this in the README.

@renanwilliam
Copy link

This works fine but I have a problem with debugging not stepping over (only stops on break-points).
It's usable but no ideal.

Any lights?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants