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










3















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










share|improve this question
























  • exclude jest-lock.json from what's being watched - stackoverflow.com/questions/40486567/… feels appropriate here.

    – Mike 'Pomax' Kamermans
    Nov 15 '18 at 1:44












  • Thanks for answering @Mike'Pomax'Kamermans , I just implemented watchPathIgnorePatterns, testPathIgnorePatterns and modulePathIgnorePatterns just to be sure, but sadly it's still in an infinite loop. Have you run --json and --watch simultaneously without this behaviour?

    – fillipvt
    Nov 15 '18 at 3:08












  • Can't say I've used jest before, just react with webpack and chokidar.

    – Mike 'Pomax' Kamermans
    Nov 15 '18 at 5:31











  • you need to turn off the hotkey "a" from being used. This is usually what causes the loop. Though it is inconsistent, removing the hotkey from being pressed will not ever cause the loop.

    – DeerSpotter
    Nov 28 '18 at 14:12















3















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










share|improve this question
























  • exclude jest-lock.json from what's being watched - stackoverflow.com/questions/40486567/… feels appropriate here.

    – Mike 'Pomax' Kamermans
    Nov 15 '18 at 1:44












  • Thanks for answering @Mike'Pomax'Kamermans , I just implemented watchPathIgnorePatterns, testPathIgnorePatterns and modulePathIgnorePatterns just to be sure, but sadly it's still in an infinite loop. Have you run --json and --watch simultaneously without this behaviour?

    – fillipvt
    Nov 15 '18 at 3:08












  • Can't say I've used jest before, just react with webpack and chokidar.

    – Mike 'Pomax' Kamermans
    Nov 15 '18 at 5:31











  • you need to turn off the hotkey "a" from being used. This is usually what causes the loop. Though it is inconsistent, removing the hotkey from being pressed will not ever cause the loop.

    – DeerSpotter
    Nov 28 '18 at 14:12













3












3








3


1






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










share|improve this question
















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







jestjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 16:40









skyboyer

3,92311230




3,92311230










asked Nov 15 '18 at 1:33









fillipvtfillipvt

38218




38218












  • exclude jest-lock.json from what's being watched - stackoverflow.com/questions/40486567/… feels appropriate here.

    – Mike 'Pomax' Kamermans
    Nov 15 '18 at 1:44












  • Thanks for answering @Mike'Pomax'Kamermans , I just implemented watchPathIgnorePatterns, testPathIgnorePatterns and modulePathIgnorePatterns just to be sure, but sadly it's still in an infinite loop. Have you run --json and --watch simultaneously without this behaviour?

    – fillipvt
    Nov 15 '18 at 3:08












  • Can't say I've used jest before, just react with webpack and chokidar.

    – Mike 'Pomax' Kamermans
    Nov 15 '18 at 5:31











  • you need to turn off the hotkey "a" from being used. This is usually what causes the loop. Though it is inconsistent, removing the hotkey from being pressed will not ever cause the loop.

    – DeerSpotter
    Nov 28 '18 at 14:12

















  • exclude jest-lock.json from what's being watched - stackoverflow.com/questions/40486567/… feels appropriate here.

    – Mike 'Pomax' Kamermans
    Nov 15 '18 at 1:44












  • Thanks for answering @Mike'Pomax'Kamermans , I just implemented watchPathIgnorePatterns, testPathIgnorePatterns and modulePathIgnorePatterns just to be sure, but sadly it's still in an infinite loop. Have you run --json and --watch simultaneously without this behaviour?

    – fillipvt
    Nov 15 '18 at 3:08












  • Can't say I've used jest before, just react with webpack and chokidar.

    – Mike 'Pomax' Kamermans
    Nov 15 '18 at 5:31











  • you need to turn off the hotkey "a" from being used. This is usually what causes the loop. Though it is inconsistent, removing the hotkey from being pressed will not ever cause the loop.

    – DeerSpotter
    Nov 28 '18 at 14:12
















exclude jest-lock.json from what's being watched - stackoverflow.com/questions/40486567/… feels appropriate here.

– Mike 'Pomax' Kamermans
Nov 15 '18 at 1:44






exclude jest-lock.json from what's being watched - stackoverflow.com/questions/40486567/… feels appropriate here.

– Mike 'Pomax' Kamermans
Nov 15 '18 at 1:44














Thanks for answering @Mike'Pomax'Kamermans , I just implemented watchPathIgnorePatterns, testPathIgnorePatterns and modulePathIgnorePatterns just to be sure, but sadly it's still in an infinite loop. Have you run --json and --watch simultaneously without this behaviour?

– fillipvt
Nov 15 '18 at 3:08






Thanks for answering @Mike'Pomax'Kamermans , I just implemented watchPathIgnorePatterns, testPathIgnorePatterns and modulePathIgnorePatterns just to be sure, but sadly it's still in an infinite loop. Have you run --json and --watch simultaneously without this behaviour?

– fillipvt
Nov 15 '18 at 3:08














Can't say I've used jest before, just react with webpack and chokidar.

– Mike 'Pomax' Kamermans
Nov 15 '18 at 5:31





Can't say I've used jest before, just react with webpack and chokidar.

– Mike 'Pomax' Kamermans
Nov 15 '18 at 5:31













you need to turn off the hotkey "a" from being used. This is usually what causes the loop. Though it is inconsistent, removing the hotkey from being pressed will not ever cause the loop.

– DeerSpotter
Nov 28 '18 at 14:12





you need to turn off the hotkey "a" from being used. This is usually what causes the loop. Though it is inconsistent, removing the hotkey from being pressed will not ever cause the loop.

– DeerSpotter
Nov 28 '18 at 14:12












1 Answer
1






active

oldest

votes


















0














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)






share|improve this answer


















  • 1





    I have here a repo where you can reproduce the problem: github.com/fillipvt/jest-watch-json-infinite-loop And I've reported this in Jest too github.com/facebook/jest/issues/7389 no solution yet

    – fillipvt
    Nov 30 '18 at 6:50











  • Thank you for the REPO, i will test when i go home today. Can i ask why this is important for you? Or just Bug hunting?

    – DeerSpotter
    Nov 30 '18 at 14:54











  • This is important, at least for me, in order to focus on the development of small components using StorybooksJS and create unit tests along with them without the need to have a separate server running the test suite. It's all just in one command. It might be a slight none critical bug at first sight but it can save a few minutes that might compound later down the road making it a somewhat noticeable problem.

    – fillipvt
    Dec 1 '18 at 0:10










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311213%2fhow-to-avoid-infinite-loop-with-json-and-watch-using-jest%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














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)






share|improve this answer


















  • 1





    I have here a repo where you can reproduce the problem: github.com/fillipvt/jest-watch-json-infinite-loop And I've reported this in Jest too github.com/facebook/jest/issues/7389 no solution yet

    – fillipvt
    Nov 30 '18 at 6:50











  • Thank you for the REPO, i will test when i go home today. Can i ask why this is important for you? Or just Bug hunting?

    – DeerSpotter
    Nov 30 '18 at 14:54











  • This is important, at least for me, in order to focus on the development of small components using StorybooksJS and create unit tests along with them without the need to have a separate server running the test suite. It's all just in one command. It might be a slight none critical bug at first sight but it can save a few minutes that might compound later down the road making it a somewhat noticeable problem.

    – fillipvt
    Dec 1 '18 at 0:10















0














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)






share|improve this answer


















  • 1





    I have here a repo where you can reproduce the problem: github.com/fillipvt/jest-watch-json-infinite-loop And I've reported this in Jest too github.com/facebook/jest/issues/7389 no solution yet

    – fillipvt
    Nov 30 '18 at 6:50











  • Thank you for the REPO, i will test when i go home today. Can i ask why this is important for you? Or just Bug hunting?

    – DeerSpotter
    Nov 30 '18 at 14:54











  • This is important, at least for me, in order to focus on the development of small components using StorybooksJS and create unit tests along with them without the need to have a separate server running the test suite. It's all just in one command. It might be a slight none critical bug at first sight but it can save a few minutes that might compound later down the road making it a somewhat noticeable problem.

    – fillipvt
    Dec 1 '18 at 0:10













0












0








0







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)






share|improve this answer













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)







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 28 '18 at 14:24









DeerSpotterDeerSpotter

298217




298217







  • 1





    I have here a repo where you can reproduce the problem: github.com/fillipvt/jest-watch-json-infinite-loop And I've reported this in Jest too github.com/facebook/jest/issues/7389 no solution yet

    – fillipvt
    Nov 30 '18 at 6:50











  • Thank you for the REPO, i will test when i go home today. Can i ask why this is important for you? Or just Bug hunting?

    – DeerSpotter
    Nov 30 '18 at 14:54











  • This is important, at least for me, in order to focus on the development of small components using StorybooksJS and create unit tests along with them without the need to have a separate server running the test suite. It's all just in one command. It might be a slight none critical bug at first sight but it can save a few minutes that might compound later down the road making it a somewhat noticeable problem.

    – fillipvt
    Dec 1 '18 at 0:10












  • 1





    I have here a repo where you can reproduce the problem: github.com/fillipvt/jest-watch-json-infinite-loop And I've reported this in Jest too github.com/facebook/jest/issues/7389 no solution yet

    – fillipvt
    Nov 30 '18 at 6:50











  • Thank you for the REPO, i will test when i go home today. Can i ask why this is important for you? Or just Bug hunting?

    – DeerSpotter
    Nov 30 '18 at 14:54











  • This is important, at least for me, in order to focus on the development of small components using StorybooksJS and create unit tests along with them without the need to have a separate server running the test suite. It's all just in one command. It might be a slight none critical bug at first sight but it can save a few minutes that might compound later down the road making it a somewhat noticeable problem.

    – fillipvt
    Dec 1 '18 at 0:10







1




1





I have here a repo where you can reproduce the problem: github.com/fillipvt/jest-watch-json-infinite-loop And I've reported this in Jest too github.com/facebook/jest/issues/7389 no solution yet

– fillipvt
Nov 30 '18 at 6:50





I have here a repo where you can reproduce the problem: github.com/fillipvt/jest-watch-json-infinite-loop And I've reported this in Jest too github.com/facebook/jest/issues/7389 no solution yet

– fillipvt
Nov 30 '18 at 6:50













Thank you for the REPO, i will test when i go home today. Can i ask why this is important for you? Or just Bug hunting?

– DeerSpotter
Nov 30 '18 at 14:54





Thank you for the REPO, i will test when i go home today. Can i ask why this is important for you? Or just Bug hunting?

– DeerSpotter
Nov 30 '18 at 14:54













This is important, at least for me, in order to focus on the development of small components using StorybooksJS and create unit tests along with them without the need to have a separate server running the test suite. It's all just in one command. It might be a slight none critical bug at first sight but it can save a few minutes that might compound later down the road making it a somewhat noticeable problem.

– fillipvt
Dec 1 '18 at 0:10





This is important, at least for me, in order to focus on the development of small components using StorybooksJS and create unit tests along with them without the need to have a separate server running the test suite. It's all just in one command. It might be a slight none critical bug at first sight but it can save a few minutes that might compound later down the road making it a somewhat noticeable problem.

– fillipvt
Dec 1 '18 at 0:10



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311213%2fhow-to-avoid-infinite-loop-with-json-and-watch-using-jest%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto