TOPIC 44/6017 MINNOT STARTED

Parameterized and data-driven tests, and environment variables

Write one test and run it with many sets of data, and switch the site address or a secret from outside the code, without copying the test.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: one recipe cooked with different ingredients. A cook has one recipe for soup. Today it is carrots. Tomorrow it is tomatoes. The steps stay the same. Only the ingredients change. Nobody writes a new recipe for each vegetable.

Daily List is a to-do list app. Tom, the tester, wants to check that Add task accepts different kinds of name. He wants a short name, a long name, a name with a number and a name with an emoji. He could copy one test four times. Then a change to the steps means four edits.

What it is: Playwright is a free tool, made by Microsoft, that drives real web browsers from test code. This topic is about two habits that work with its . The first is a parameterized test: you write the steps once and feed in many sets of data. The data are called . The second is an environment variable, a setting that lives outside your code, such as the website address. Neither habit is a Playwright invention. Playwright lets you do both with ordinary JavaScript or TypeScript, so there is no special add-on to learn.

Why it matters: four near-copy tests drift apart the first time someone edits only three. One parameterized test feeds four names through the same steps, so Tom changes the path once and covers every case. A site address and a password kept outside the code let the same tests run on a test site, on staging and on the .

The picture has a limit. A soup recipe tastes different with each vegetable, but a test must still check the right thing for each one.

Kept simple: this lesson covers a loop and a settings file. Playwright also has per-project settings, which a later lesson covers.

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

PLAIN WORDS · 4 in this section
emoji
a small picture character, such as a smiling face
playwright
a free Microsoft tool that drives a browser for tests
parameterized
sending values apart from the command so they cannot alter
typescript
JavaScript with added labels for the kinds of data

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 Running the same steps with many inputs, and pointing the same tests at different copies of the app, without copying anything.

  1. Write the steps once
  2. List the data
  3. Loop to make tests
  4. Set the kitchen from outside
One recipe, many ingredients, any kitchen

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
The recipeThe test steps
The ingredientsThe list of test data
The kitchen you cook inThe environment, set from outside
The key to the pantryA secret kept out of the code

WHERE THIS PICTURE STOPS

  • A recipe tastes different with each vegetable, but a test must check the right thing for each input.
  • A cook picks ingredients by hand. A loop makes them all at file load, so the list must be ready.
  • A pantry key can be copied. A secret can leak if it is printed in a report.

HOOK

One recipe, many ingredients, any kitchen.

REMEMBER IT THIS WAY

A chunk: a long list grouped so it is easier to hold.

Write the steps once and loop the data. Tom's four names are short, long, number and emoji.

What each part of the trick stands for
In the trickWhat it stands for
shorta short name
longa long name
numbera name with a number
emojia name with an emoji

A loop makes every test at file load, so the data list must be ready first.

TELL A FRIEND

One recipe cooked with different ingredients, in whichever kitchen you are given.

OFTEN MIXED UP WITH Test structure: describe, hooks, tags, annotations and skipping. The structure lesson covers hooks and tags. This lesson uses them with loops and settings.

Sources & standards — 3 sources
  1. Market practice

    Parameterize tests (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.

    Data-generated tests and configuration. A beforeEach outside the loop is declared once but executes before every selected test; the guide wording about executing once must not be read as once per file. Per-item describe gives item-specific hook scope. · 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

    III. Config (The Twelve-Factor App) ↗ — Adam Wiggins · Keep config, including credentials, in the environment and not in the code (search excerpt, page not opened)

    Says config is whatever changes between deploys and should be kept in the environment, not in the code. Practitioner guidance, 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. 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.

  3. Market practice

    Playwright Test class reference (Playwright documentation) ↗ — Microsoft (Playwright) · test.step groups actions under a name in the report; test.info() returns the TestInfo of the running test (search excerpt, page not opened)

    Reference for test, test.step, test.setTimeout, test.slow and test.only. Says test.step declares a step that is shown in the report and can be nested, test.slow gives a test triple the default timeout and test.setTimeout sets an explicit limit. Vendor documentation for one tool. Practitioner guidance, 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. 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 — 3 sources
  1. Market practice

    Parameterize tests (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.

    Data-generated tests and configuration. A beforeEach outside the loop is declared once but executes before every selected test; the guide wording about executing once must not be read as once per file. Per-item describe gives item-specific hook scope. · 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

    III. Config (The Twelve-Factor App) ↗ — Adam Wiggins · Keep config, including credentials, in the environment and not in the code (search excerpt, page not opened)

    Says config is whatever changes between deploys and should be kept in the environment, not in the code. Practitioner guidance, 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. 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.

  3. Market practice

    Playwright Test class reference (Playwright documentation) ↗ — Microsoft (Playwright) · test.step groups actions under a name in the report; test.info() returns the TestInfo of the running test (search excerpt, page not opened)

    Reference for test, test.step, test.setTimeout, test.slow and test.only. Says test.step declares a step that is shown in the report and can be nested, test.slow gives a test triple the default timeout and test.setTimeout sets an explicit limit. Vendor documentation for one tool. Practitioner guidance, 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. 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.