Your First Test
Explore how to create your first UI test using Jest in React. Learn to write readable test cases, use assertion methods like toEqual and toBeTruthy, and understand how specific predicates enhance debugging. This lesson helps you gain foundational skills for testing React components effectively.
We'll cover the following...
Jest test
A Jest test uses the it function, which takes two arguments. The first argument is the name of the test. By convention, it’s written to be read with the word “it”. So, below, we see it('sums numbers', ...) reads like “it sums numbers”. We should try to keep the test names as readable and meaningful as we can. The test results will show this string together with the test result and the time it took. The second argument is a function, typically written using the arrow notation.
Try it yourself
We’ve ...