TOPIC 13/6020 MINNOT STARTED

Test structure: describe, hooks, tags, annotations and skipping

Group Playwright tests with describe, share set-up with hooks, label them with tags, and mark tests that must wait with skip or fixme.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: chapters, a bookmark, and sticky notes in a workbook. Loose pages are hard to use. Chapters group them. A bookmark jumps to one page. A sticky note marks the pages that matter today.

Daily List is a to-do list app. Tom has tests/tasks.spec.ts with twelve tests in one heap. Each test starts by opening the site. Mei, the test lead, wants a way to run only the smoke checks before a release.

What it is: Playwright is a library that drives a real browser. This slice is how you group tests, share setup, and mark tests you want to run or park. A is the chapter. A is the shared step. A test annotation can affect execution or simply add report metadata. Selenium and Cypress group tests too, and the method names differ.

Why it matters: Twelve copies of the same open-the-site lines drift apart the first time the address changes. One hook keeps that step in one place. Tags let Mei run a small set without commenting tests out.

Workbook pages stay in order. Playwright may run files side by side. A hook must not assume that test two sees what test one left behind.

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

PLAIN WORDS · 7 in this section
bookmark
a saved web address in a browser
workbook
one file holding several linked grids of numbers
playwright
a free Microsoft tool that drives a browser for tests
annotation
a short note added to explain or comment
metadata
extra details that describe the main data
selenium
A free tool that drives a web browser for checks.
cypress
A free tool that drives a web browser for checks.

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 Keeping a growing test file readable, runnable in parts and honest about tests that cannot run.

  1. Group with describe
  2. Share with a hook
  3. Label with a tag
  4. Pick with --grep
Group it, label it, then pick it

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
ChaptersDescribe blocks
A bookmarkA --grep run that jumps to chosen tests
Sticky notesTags and annotations
Setting the table before each pageA beforeEach hook

WHERE THIS PICTURE STOPS

  • A workbook is read in order, but Playwright may run tests side by side.
  • A sticky note never changes a page, but test.skip changes whether the test runs.
  • A loose bookmark is harmless, but a left-behind test.only hides tests.

HOOK

Chapters, sticky notes, bookmark.

REMEMBER IT THIS WAY

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

If twelve tests start with the same two lines, move them into one beforeEach hook.

What each part of the trick stands for
In the trickWhat it stands for
Same two linesopen the site, then log in
beforeEach hooka hook that runs before each test

A line that only one test needs should stay inside that test.

TELL A FRIEND

A workbook with chapters, sticky notes and a bookmark. Chapters group, notes label, and the bookmark takes you to the pages you choose.

OFTEN MIXED UP WITH Fixtures: shared setup without copy-paste. Hooks run the same set-up around every test. A fixture is set-up a test asks for by name, so only the tests that need it pay for it.

Sources & standards — 3 sources
  1. Market practice

    Annotations (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.

    Says test.skip marks a test that does not apply in some setup, test.fixme marks a test to be fixed, a describe call takes a details object with tag and annotation, each tag starts with @, and --grep and --grep-invert filter by tag. Vendor documentation for one tool. Practitioner guidance, 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

    Playwright Test class reference (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: beforeEach, step, fail and locks type definitions. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Documents test.describe, the hooks beforeEach, afterEach, beforeAll and afterAll, test.skip, test.fixme, test.slow and test.step. Vendor documentation for one tool. Practitioner guidance, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: beforeEach, step, fail and locks type definitions. 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

    Command line (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.

    Lists the npx playwright test options, including --grep, --grep-invert, --project and --no-deps. Vendor documentation for one tool. Practitioner guidance, 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.

PRACTISE AND KEEP

Sources for this topic — 3 sources
  1. Market practice

    Annotations (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.

    Says test.skip marks a test that does not apply in some setup, test.fixme marks a test to be fixed, a describe call takes a details object with tag and annotation, each tag starts with @, and --grep and --grep-invert filter by tag. Vendor documentation for one tool. Practitioner guidance, 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

    Playwright Test class reference (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: beforeEach, step, fail and locks type definitions. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Documents test.describe, the hooks beforeEach, afterEach, beforeAll and afterAll, test.skip, test.fixme, test.slow and test.step. Vendor documentation for one tool. Practitioner guidance, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: beforeEach, step, fail and locks type definitions. 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

    Command line (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.

    Lists the npx playwright test options, including --grep, --grep-invert, --project and --no-deps. Vendor documentation for one tool. Practitioner guidance, 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.

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.