question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Watching tests not working with IntelliJ's Jest Run Configuration

See original GitHub issue

We recently switched from react-scripts v1 to v2. And with that, we now also use craco to rewire some configurations. (Thanks btw. for the awesome package. We used react-app-rewired and the configuration for craco is much nicer and easier to understand!)

Everything works fine so far, except the watch mode of tests in IntelliJ’s Jest Run Configuration does not work properly. The first run passes without any problem, but as soon as a file changes and a new test run is therefor triggered, the src/setupTests.ts file is not loaded again. Meaning that enzyme throws an error since no enzyme adapter is configured any more. (Other packages also throw errors since they are not initialized properly)

When I run the test in the regular terminal with the same configuration that I apply in IntelliJ (e.g. yarn run craco test --env=jsdom --watch), watching works normally and does not throw any errors.

Does anyone know how to fix this? I really do not want to loose the IntelliJ test result reporting since it makes working with tests so much easier.

I’m using react-script@2.1.1 and craco@3.1.1 if that makes any difference.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Lukas-Kullmanncommented, Jan 8, 2019

Just to give you an update on this, it works in the new 2018.3.2 version of IntelliJ, which was released Dec. 19th 2018. 😃

0reactions
patricklafrancecommented, Dec 11, 2018

I will close this issue, @Lukas-Kullmann feel free to open it again once you have news from IntelliJ

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest | IntelliJ IDEA Documentation - JetBrains
You can run and debug tests with Jest right in IntelliJ IDEA. You can see the test results in a treeview and easily...
Read more >
Running Jest in watch mode not working
I'm trying to get Jest tests to rerun upon file change rather than restarting the tests all over I added --watch to the...
Read more >
Run/Debug Configuration: Jest | IntelliJ IDEA Documentation
In this dialog, create configurations for running Jest tests. ... search is performed in the file system upwards from the working directory.
Read more >
Running a jest test from within the test file sets wrong cwd
As a workaround I have been setting project root path in Run Configurations > Defaults > Jest > Working directory. But I noticed...
Read more >
Error while running jest test case in intellij through jest config.
Hi Team, Facing this issue while running the jest test case through configuration. Please look into this. module exists though in the node_modules...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found