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.

While using jest-addon with --json and --watch together an infinite loop is triggered

See original GitHub issue

Describe the bug When using --json and --watch together a infinite jest test loop occurs

To Reproduce Steps to reproduce the behavior:

  1. Create a simple jest test
  2. Implement jest-addon
  3. Create a script like this: "test:output:watch": "jest --json --outputFile=jest-lock.json --watch"
  4. 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:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
rafistrausscommented, Jan 29, 2019

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 modulePathIgnorePatterns in your Jest config:

// my output json file is named jest-test-results.json, so:
modulePathIgnorePatterns: ['node_modules', 'jest-test-results.json'],
1reaction
fev4commented, Feb 20, 2019

With the workaround the loop doesn’t happen. Thank you all

Read more comments on GitHub >

github_iconTop 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 >

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