From the course: Building Test-Driven React Components with Copilot

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Refactoring tests

Refactoring tests

- [Instructor] Our tests are working, but there is a bit of a problem here, and that problem has to do with local storage. So sometimes sharing state across different local storage instances can be a little bit troubling, a little bit problematic. So we're going to add a cleanup here between tests. So what we'll do is we'll say add beforeEach to clear localStorage before each test. So we'll give that a save. And we could also put this at the top of the scope actually, so that this happens before each test. Now make sure that that doesn't slow down your testing process too much, but this is a nice feature. I'm going to cancel the test and rerun them just to make sure everything's working as we expect it to. And there we go. Let's also add a little bit of organization here. So let me also add a little bit of organization here. I'm going to say organize these tests into logical groups. And this is going to add a…

Contents