TOPIC 45/6018 MINNOT STARTED

Test data management for Playwright suites

Give every test the data it needs, keep parallel tests from fighting over the same records, and clean up afterwards so the next run starts fresh.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: stocking the pantry before the cooks arrive. Picture four cooks starting to work in one kitchen at the same time. If there is one jar of salt, they will bump into each other, and one will find it empty. If each cook has a labelled box of ingredients, they can all work. After the meal, someone must clear the boxes, or the next day starts with a mess.

Daily List is a to-do list app. Tom, the tester, runs four tests at once. All four log in as the same user. One test deletes all tasks, and another test then cannot find the task it just added.

What it is: Playwright is a free tool, made by Microsoft, that drives real web browsers from test code. is the information a test needs, such as an account, a list or a task. Test data management is how a suite creates that data, keeps it apart between tests and removes it afterwards. Playwright has no database of its own for this. It gives you the parts: parallel workers, , fixtures and a request helper that calls the app's own application programming interface. You put them together.

Why it matters: shared users and shared tasks make parallel runs collide. Giving each test its own data, and clearing it after, keeps failures about the product and not about who deleted whose list.

The fix is not to run fewer tests at once. The fix is to give each test its own ingredients and to clear them afterwards. The picture has a limit. Real kitchens do not clean themselves, and neither do test sites. Someone must write the clean-up.

Kept simple: this lesson assumes the test site has an interface for creating and deleting data.

(SYNTHETIC / TRAINING ONLY: Daily List, its test site and every person named here are made up.)

PLAIN WORDS · 3 in this section
pantry
a cupboard or room where food is stored
playwright
a free Microsoft tool that drives a browser for tests
collide
clash because they use the same thing

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.

THE REAL JOB Giving every parallel test its own data, and removing what it made, so runs do not disturb each other.

  1. Find the clash
  2. Make data unique
  3. Give workers their own
  4. Clean up after use
Own box, unique labels, clear the table

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
The cooksParallel workers
The labelled box of ingredientsUnique data owned by one worker
The shopping before the mealSeeding through the application interface
Clearing the boxes after the mealClean-up in a fixture

WHERE THIS PICTURE STOPS

  • Real kitchens do not clean themselves, and test sites do not either. Someone must write the clean-up.
  • Cooks can share salt safely if they only look at it. Read-only data can be shared too.
  • A kitchen has a shop nearby. A test site needs a way to create data, which may have to be built.

HOOK

Own box, unique labels, clear the table.

REMEMBER IT THIS WAY

A rule of thumb: if you see this, think that.

Own box, unique labels, clear the table. If tests run at once, usually give each one its own data and clean it up after.

What each part of the trick stands for
In the trickWhat it stands for
own boxunique data owned by one worker
clearclean-up in a fixture

Read-only data can be shared safely between workers.

TELL A FRIEND

Stock a labelled box for every cook before the meal, and clear the boxes afterwards.

OFTEN MIXED UP WITH Fixtures: shared setup without copy-paste. The fixtures lesson explains the helper that sets up and tears down. This lesson uses fixtures for data.

Sources & standards — 4 sources
  1. Market practice

    Parallelism (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Describes workers and how to give each worker its own data. Vendor documentation, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  2. Market practice

    Fixtures (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Fixture setup/hand-off/teardown, dependencies, lazy and automatic fixtures, test/worker scope and options. Test-scoped page cannot be consumed by a worker-scoped fixture. Hooks and dependent fixtures can request values too. Cleanup is attempted under the runner lifecycle, not guaranteed after a hard kill or setup that fails before hand-off. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  3. Market practice

    Test info (Playwright documentation) ↗ — Microsoft (Playwright) · testInfo.attach takes a name and either a body or a path, not both; outputPath gives a file path inside the test's own output folder that is safe when tests run in parallel; workerIndex and parallelIndex identify the worker (search excerpt, page not opened)

    Describes the TestInfo object: attach, outputPath, retry, workerIndex and parallelIndex. Vendor documentation, not a standard. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  4. Market practice

    Deterministic state and test isolation (Steve Kinney, Self-Testing Artificial Intelligence Agents course) ↗ — Steve Kinney · Seed a fixed data set before each test; reseeding is cheap with a small local database and costly with a larger one, where seeding per file or using transactions is an alternative (search excerpt, page not opened)

    A practitioner course page on seeding and isolating test data. Practitioner view, not a standard. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

PRACTISE AND KEEP

Sources for this topic — 4 sources
  1. Market practice

    Parallelism (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Describes workers and how to give each worker its own data. Vendor documentation, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  2. Market practice

    Fixtures (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Fixture setup/hand-off/teardown, dependencies, lazy and automatic fixtures, test/worker scope and options. Test-scoped page cannot be consumed by a worker-scoped fixture. Hooks and dependent fixtures can request values too. Cleanup is attempted under the runner lifecycle, not guaranteed after a hard kill or setup that fails before hand-off. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  3. Market practice

    Test info (Playwright documentation) ↗ — Microsoft (Playwright) · testInfo.attach takes a name and either a body or a path, not both; outputPath gives a file path inside the test's own output folder that is safe when tests run in parallel; workerIndex and parallelIndex identify the worker (search excerpt, page not opened)

    Describes the TestInfo object: attach, outputPath, retry, workerIndex and parallelIndex. Vendor documentation, not a standard. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  4. Market practice

    Deterministic state and test isolation (Steve Kinney, Self-Testing Artificial Intelligence Agents course) ↗ — Steve Kinney · Seed a fixed data set before each test; reseeding is cheap with a small local database and costly with a larger one, where seeding per file or using transactions is an alternative (search excerpt, page not opened)

    A practitioner course page on seeding and isolating test data. Practitioner view, not a standard. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.