How To Get Started Testing React With Jest

After you have updated your JSX, you may find that your snapshot test will fail.  This should be pretty obvious to understand.  You've changed the markup so the final component will now look different. 

To correct this is fairly simple.  All you need to do is take a fresh snapshot, check it in and job done.  Simple.  To update a snapshot, simply run jest with the --updateSnapshot flag, like so:

jest --updateSnapshot

A good resource on getting started with Jest can be found here, which I suggest that you check out.

submit to reddit

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

Back to top