Learning Unit testing - Jest and React Testing Library
Read about how to begin unit testing in your project, what are the challenges you might face, and my short story around learning unit testing.
Table of Content
- Jest, React Testing library and Enzyme
- Unit testing in Create React App (CRA)
- Mocking - When to use what?
- Async function testing
- Route testing
- Assertions, global methods, and cleanup
- Formik testing
- What you should avoid with React Testing Library
- Testing hygiene
- Visual satisfaction
- Resources
(Click on poster to zoom)
It was long due that I paid. I wanted to learn unit testing but never moved towards it. Finally, I decided and the day came when I started learning from the TestingJavaScript course by KCD. I was blown away 🤯 when he showed a simple assertion without any library.
// Function - Often referred as test subject
const sum = (a, b) => a - b;
// Function to make assertion
function expect(actual) {
return {
...