This course has been updated! We now recommend you take the Intermediate React, v5 course.

Check out a free preview of the full Intermediate React course:
The "Jest Watch" Lesson is part of the full, Intermediate React course featured in this preview video. Here's what you'd learn in this lesson:

Jest Watch will run your tests as you're modifying files to get constant feedback on your code. Jest Watch also has smart performance features to keep your tests running fast as you code.

Get Unlimited Access Now

Transcript from the "Jest Watch" Lesson

>> Brian: Show you one more cool feature about Jest that I like, npm run test, and if I do --, anything that I put after the -- will actually pass to Jest. So I can put -- watch, like that, and run it. And it's actually gonna run Jest in an interactive mode which I find to be fascinating.

[00:00:20] So I can just hit A, and it'll rerun all the test again for me.
>> Brian: Or I can tell to, only run some tests, right? But it'll actually be file watching all of my modules. And if I change anything inside details, it'll rerun the test because it knows that the details test pulls in the details module, right?

[00:00:41] So, let's go make it fail again. If I turn this to true. Saved it. Now, I have to go back over here and it's going to say, hey, that failed, right? You get instant feedback that that failed. And then, if I go back and change it to false again, it goes, no, I'm happy.

[00:00:56] So, it only runs the subset of tests that could have possibly failed in the interim. I don't know if any of you have enormous test feats that take minutes to run. This is a godsend for those sorts of people, right? Something else that just does that's really intelligent, it runs the last test to fail first.

[00:01:17] So it'll actually run your tests out of order, because it wants to fail as fast as possible. Which I also find to be extremely useful. So, let's go ahead and add that to our pax.json as well.
>> Brian: So, we have test update here, test : watch. This is jest -- silent -- watch, like that.

>> Brian: And now, you can just say, mpm run test : watch, and it puts you right into that mode right away.