- Practice writing tests with Jest
- Catch any bugs in your project's object-oriented code
Now that you've put your frontend together, you'll write Jest tests to ensure your code works as expected.
Don't worry about testing React components, you'll do that in the RTL lesson. With Jest you'll focus on testing the functions you've written.
- Create a test folder, and start with a new file for Events. The curriculum outline about Jest can remind you how to structure this.
- In your project root, run
jest
(it will start your tests). - A lot of them will fail or not be found, and your challenge is to fix them. Debug why the tests are failing and update the Jest code and/or your classes to make the tests pass. Every time you make a fix, run
jest
again to check your tests. This might take a while but is good practice for debugging both your tests and your code. - When you get the existing tests working, add tests for other functions you have implemented.
- Add at least one more test of your choice. What else could be useful to test in your code?