This is why you do not need to import expect and describe into this file. Jest is the environment where all your tests are actually executed. Jest is the test runner and testing framework used by React. Unlike your react components, your tests are not executed in the browser.
The tests will pass if your hypothesis is correct and fail if it is wrong. Then you assert, or make a hypothesis, of the new state of your app. Once all brackets are in place, place your curtains onto your curtain rod.
Act, then something happens (click event, input, etc.). Complete this step for the one or two other brackets. Testing is a 3 step process that looks like this:Īrrange, your app is in a certain original state. Let's start at the beginning and discuss what testing is. However, it will be a complete foundational guide to testing and will be enough to build off of for most other edge cases.Īlso I have curated an extensive collection of blog posts, articles and tutorials in the further reading section at the end that should give you enough knowledge to be in the top 10% of developers in terms of testing. So I decided to just write a complete React testing guide in one article.Ĭomplete Guide, huh, are you going to cover every possible testing scenario? Of course not. I found this to be true as well for React testing. When I first started learning to test my apps back in the day, I would get very frustrated with the different types, styles and technologies used for testing, along with the disbanded array of blog posts, tutorials and articles.