-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Running Jest from within PHPStorm #862
Comments
It's my bad. I didn't use the Unfortunately my IDE (PHPStorm) doesn't work well with running jest via npm/yarn :-(. Any solutions for that? |
hi @michelcve came across this kind of issue too, maybe #747 is useful for you somehow? how do you integrate jest within your IDE? I am using vscode, how does your current setup in your IDE look like? how is it done there? would be interesting to know... ps: from |
@skydever I'm using PHPStorm, configuring Jest is described here: https://www.jetbrains.com/help/phpstorm/running-unit-tests-on-jest.html I cannot use the trick on #747, since I'm only allowed to pick a Jest package (or some react scripts thingy), so I can't run NPM from there. I did try making a 'fake' jest package, which calls NPM, but the IDE isn't picking up the output correctly, so that didn't quite work. As for the .ts... well, the file 'account-anonymous.ts' has the 'import @webfrontendclient/states/ngrx-helpers', so that's why it's referring to that .ts file. |
Another thing I'm trying right now is to get jest running without the npm scripts. I managed to solve the @ imports by changing the jest.config.js to this:
However, I have two errors remaining after that, that still need to be addressed:
Still looking into these two at the moment. |
Coverage integration works somewhat, by adding the "lcov" option to the coverageReports in jest.config.ts. and combining that with a batch file that creates a lcov.info file in the root of the coverage directory, that is a concatenation of all lcov.info files from all subdirectories. You should run that batch file after e.g. fixCoverageForPHPStorm.bat:
|
Okay, I spoke too soon. Actually #747 did help me a lot, thanks! I now have jest integration in PHPStorm working (although it runs all tests, not just the affected). Personally, I'm very happy with how it works. This is what I ended up doing:
|
Bro you are my hero. |
Because I landed here via google... #1439 (comment) was the solution which worked for me.
|
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
When running a unit test with Jest for a component that has an import starting with an @, Jest can't resolve the path, and will throw an error similar to this:
Cannot find module '@webfrontendclient/states/ngrx-helpers' from 'account-anonymous.ts'
The text was updated successfully, but these errors were encountered: