Loading
Current section: Unit Testing 6 exercises
Problem

Implementing Test Hooks for Error Restoration in Playwright

Loading exercise

Transcript

00:00 You may recall that we had a problem before with Playwright when we do some clean-up at the end of the test. And that is, if we have some sort of error, throw a new error, blah. Now, once we get to this console error step, this doesn't end up restoring,

00:19 and that's going to be a problem for us, because then future tests will not have the error restored back to its original implementation. So that's going to be a problem for us. And on top of that, we want to actually do this in a couple places.

00:34 So we're going to be using hooks to make—not React hooks, folks, but testing hooks— to make it so that we can do this setup and reuse this all over the place. And then we're also going to be making it so that our mock is restored by default by configuring the test.

00:54 So you've got two things to do in this part of the exercise. Go forth and have an awesome time doing it.