Loading
Current section: End-to-End 6 exercises
Problem

Isolating Tests for Better Reliability and Flexibility

Loading exercise

Transcript

00:00 Typically, it's a really bad idea to make your test rely on something outside of the test. And the reason for that is if somebody changes the setup for some reason and then pushes that, and then later you run your test and you're like, oh, this is broken now, and I have no idea why.

00:16 And so there's that level of indirection that makes it a lot trickier to make your life happy. So what I recommend instead is you have your test be able to be completely isolated. So it takes care of all of the setup that is necessary. And what's really cool about Playwright is all of our tests are running in Node.

00:36 And so they have access to whatever APIs that we want. And in fact, we can even import our files from our Node project as well. And so we can grab our database client and run that and it works perfectly well. It's awesome. So that's what you're going to be doing in this exercise.

00:52 I want you to create a user and then query for that user instead of querying for Cody. And that is what we're going to do for this exercise. Have a good time.