The Composition of a Test
Explore the key components of a Jest test, including setting expectations and using assertions to validate outcomes. Understand how to write straightforward tests that confirm functions behave as intended, aiding in producing maintainable and resilient JavaScript code.
We'll cover the following...
We'll cover the following...
Now that we have an understanding of the Jest setup, we can learn how to write a test.
In layman’s terms
Simply put, a test does exactly one thing. A test tells us whether Y is true if we’re given X. X can be an argument passed to a function, an API response, a state, or a sequence of user behaviors, while Y can be a return value, the calling of a function, presence in the DOM, an error, etc.
Another ...