How to avoid infinite loop with --json and --watch using jest?

Viewed 1690

I'm trying to create a simple test script that when run enters watch mode and re-writes a file called jest-lock.json

"test:output:watch": "jest --json --outputFile=jest-lock.json --watch"

When this runs it simply enters an infinite loop and I'm not sure what I'm doing wrong.

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.

Thanks

1 Answers

it appears this wasnt really solved anywhere (A good challenge! if i could add my reputation with your bounty i would), this source does give good information on why watch loops.

this isnt my solution but i believe you can use this:

watch -n1 'wc -l my.log | tee -a statistics.log'

This will execute your wc each second, add its output to the statistics.log file, and also show it on the screen. So, you'll end up with a file filled with numbers, representing the successive number of lines of my.log.

now using this structure, (im not a json expert) we can restructure your line for what it should be. I may need some colleagues help with this. (a good start at least)

Related