lecture 6 of 180 completed

Tests that fight over the same data

Two tests using the same name will break each other. Give every test data that belongs only to it.

What you'll learn

  • Why two tests sharing data break each other
  • How to give every test data that belongs only to it
  • Why parallel runs make this urgent

Two engineers can spend a whole afternoon on a failing build, reading the app code, checking the database, and blaming the server, when the real cause is two tests that both created a customer named "Test User".

Let's walk through why this is so hard to see.

You have two tests. Both create a contact named "Dana Fox".

Run the first alone: it passes. Run the second alone: it passes. Run them together: the second fails, because it expected one Dana Fox and found two.

Now it gets worse. Playwright runs test files in parallel by default. So the failure moves around depending on timing. Someone re-runs the build and it passes. Nobody can reproduce it on their machine.

members only

Keep reading with the full course

The Foundations track and the first 5 lectures of each framework are free. This lecture is part of the paid course, which unlocks every lecture, all three frameworks, and downloads.

See the options →