While using jest-addon with --json and --watch together an infinite loop is triggered
See original GitHub issueDescribe the bug When using --json and --watch together a infinite jest test loop occurs
To Reproduce Steps to reproduce the behavior:
- Create a simple jest test
- Implement jest-addon
- Create a script like this:
"test:output:watch": "jest --json --outputFile=jest-lock.json --watch" - See infinite loop on console when running
nom test:output:watch
Expected behavior There shouldn’t be a infinite loop, or how can I avoid it?
System:
- OS: MacOS
- Framework: react
- Addons: jest
- Version 4.0.0
What can I do to avoid it or how can I help in order to resolve this? Is this the right place to report it?
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
While using jest-addon with --json and --watch together an ...
Describe the bug. When using --json and --watch together a infinite jest test loop occurs. To Reproduce Steps to reproduce the behavior:.
Read more >How to avoid infinite loop with --json and --watch using jest?
I have a simple test and I'm trying to do this in order to use the storybook jest-addon. Any thoughts? All is appreciated....
Read more >How to Loop Through the Array of JSON Objects in JavaScript
This tutorial will guide you on how to loop the array of JSON objects in JavaScript. We'll explain the types of loops and...
Read more >Fixing JSON Self Referencing Loop Exceptions
When building applications that use JSON, you'll often have to deal with looping. Here's the real solution to fixing JSON self-referencing ...
Read more >Intro to using JSON in Shortcuts on iPhone and iPad
Intro to using JSON in Shortcuts on iPhone and iPad. JSON is a popular data-interchange format used by APIs (application programming interfaces).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

As @igor-dv correctly reasoned, the output JSON file being (re)created on test completion is causing the watcher to rerun the tests. A simple workaround is to tell Jest to ignore the output, e.g by specifying the
modulePathIgnorePatternsin your Jest config:With the workaround the loop doesn’t happen. Thank you all