Organizing your tests in blocks of code is a great habit. In this video, Emmanuel Henri shows you how to organize your Jest tests with a method called describe. This allows your tests to have a more organized report when running them.
- [Instructor] As your list of tests grows … you might have the need to organize your tasks … beyond the simple file organization. … Each file is a test suite … and then it runs a test inside of the suite. … But you might need to organize your tests further … and you can do this with the describe method. … The main advantage of doing this … is to block your test around the context … of what you're trying to test. … Let's refactor our code a bit to demonstrate an example … and how you go about doing this. … So I'm back into the grid.test.js … where I have this big massive test here … and what I'm going to do is refactor all this. … So the first thing we're going to do … is refactor the numbers area. … So I'm going to hit return after the variable … that I created here … and I'm going to create a describe. … And this is basically how you block several tasks together. … So we're going to call this number test. … And then again it's a function. … And then all we have to do is cut the test that we have here …
- Setting up for React testing and debugging
- Testing with Jest
- Snapshot testing
- Debugging with Chrome and Chrome extensions
- Optimizing React code with ESLINT
- Type checking