This a workshop that covers the basics of testing JavaScript and React at Refresh conference.
To verify whether you have correct versions, run:
node --version
npm --version
I recommend setup this project before the workshop, so that you would have everything ready before we start.
Just follow these instructions:
- Clone this repo
- Install dependencies
npm install
- Start dev server with playground
npm start
, check on http://localhost:3000/ that application runs correctly
In this repo inside /src
folder you will find folders representing each part of the workshop.
Workshop is divided into 3 main parts:
- Part 1: what is testing, fundamentals, introduction to Jest
- Part 2: introduction to testing React components, testing-library, react-testing-library
- Part 3: testing async code, mocking API, how to apply what we learned to testing React apps
During this 3-hour workshop you will do 3 practiocal tasks on your own:
- Fundamentals of testing to practice writing tests for pure JS functions
- Testing React components to practice testing simple React components
- Testing React components with async to practice writing tests for components that use async API
In files of tasks you will find instructions and hints in code comments. Each task also has the solution defined, it is within the __solution__
folder. This folder is skipped during the test runs, but you are welcome to check out the code if you feel stuck.
Here are some additional resources I recommend looking into afterwards
- Jest
- Testing Library
- Testing library queries
- React Testing Library
- React Testing Library cheatsheet
- Kent C. Dodds's blog
I would really appreciate your anonymous feedback about the workshop!