Transcript
00:00 we've got ourselves a little bit of a problem. So every time we run this test, I seem to get another user on this user's page. So if I hit play again on this test, then refresh, oh, there's another one. So this is a problem and the solution is we need to clean up after ourselves.
00:17 The test creates a new user, but we need to make sure we get rid of that user at the end of the test. So that way we don't just keep on filling up our database with tons of nonsense data, especially as you get lots of tests, you can get lots of users added every time you run them. It's not cool. Now, around this point,
00:36 those of you who've been around the block before are probably thinking, Kent, why don't we just use a different database altogether from our development database? And so then we don't have to worry about cleanup. And you could absolutely do that, but I really like using tools like Playwright to kind of help me drive my development.
00:53 And if I was, I just really like being able to use the exact same server between what's running in Playwright and what's running in my tab. And that same server, also same database. So using a separate database is also another option, but that does not negate what you're about to learn here, which is the importance of cleanup.
01:12 Because our tests need to be isolated. We should be able to run all of the tests at the same time and they shouldn't affect each other. And they should be able to clean up or create their own setup and then clean up after they're finished. This is just a really solid testing principle. I promise you, it will save you a lot of headache
01:32 if you follow this. So whether you're gonna create a separate test database for your end-to-end tests or not, you should be doing this. Now, I'll also mention that we absolutely are going to be creating a test database for our lower level tests. And we'll get into that later on in the workshop. But for end-to-end tests,
01:51 they're running against our regular development database. And so we wanna make sure that we clean that up so we don't get this nonsense. So have a good time with that and we'll see you when you're done.