Skip to content
Back to skills

Test Standards

ASecurity

Use when creating or editing a spec file under tests/**, choosing a test type or tag, writing a data-driven loop, or wiring cleanup for a state-mutating test. Not for API coverage matrices (see `api-testing`) or factories and static data (see `data-strategy`).

  • 312 stars
  • 0 votes
  • 0 copies
  • 8 views
  • Added September 22, 2026
testingtypescriptgotestingdebuggingapi

Works with

  • api

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned November 9, 2026

npx -y skills add idavidov13/agentic-playwright --skill test-standards --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Test Standards?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Test Standards
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/idavidov13-test-standards/badge)](https://www.skillsdirectory.com/skills/idavidov13-test-standards)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: test-standards
description: Use when creating or editing a spec file under tests/**, choosing a test type or tag, writing a data-driven loop, or wiring cleanup for a state-mutating test. Not for API coverage matrices (see `api-testing`) or factories and static data (see `data-strategy`).
---

# Test Standards

## Critical

- Import `test` and `expect` from `fixtures/pom/test-options.ts`, never from `@playwright/test`.
- Each test has **exactly one** tag from `@smoke`, `@sanity`, `@regression`, `@e2e`, `@api`, `@destructive`. Never `@functional`, never a tag array, never a tag on `test.describe()`.

    ```typescript
    // CORRECT
    test('should login', { tag: '@smoke' }, async ({ appPage }) => {});
    // WRONG
    test('should login', { tag: ['@smoke', '@e2e'] }, async () => {});
    ```

- `@destructive` is the heaviest tag and always wins, but only for shared/global state (locale, permissions, roles, guest access, feature flags, global settings, shared seed data). A test that creates and removes only its own data keeps its importance tag.
- **Every state-mutating test** has a `test.afterEach()` or `test.afterAll()` hook that reverts what it wrote, and the hook succeeds after a failed test.
- Web-first assertions only: `await expect(locator).toBeVisible()`, `.toHaveText()`, `.toHaveCount()`. Never `page.waitForTimeout()`.

    ```typescript
    // CORRECT
    await expect(appPage.username).toBeVisible();
    // WRONG
    await page.waitForTimeout(1000);
    ```

- Tests **must be independent**: no ordering, no shared mutable state. Setup goes in `test.beforeEach()` or a fixture.
- Never commit explore-only or debug specs (`console.log(await page.content())`, probes).
- After adding or modifying a spec, run `npx playwright test <file>` and **confirm zero failures** before reporting done.

## Procedure

1. Classify: functional (`tests/{area}/functional/`), API (`tests/{area}/api/`), E2E (`tests/{area}/e2e/`) or setup (`tests/{area}/*.setup.ts`). Run `ls tests/` to resolve `{area}`.
2. Open the nearest spec of the same type and copy its import, `describe` and `beforeEach` shape; a spec that must start signed out (login, anonymous forms) calls `resetStorageState()` in `beforeEach`; everything else starts signed in. Skeletons: `references/spec-patterns.md`.
3. Tag the test; when unsure which importance tag applies, read `references/tags.md`.
4. Split the body into `test.step()` blocks named GIVEN / WHEN / THEN. An API test with more than one call follows `api-testing`.
5. Take values from a factory or a static `.ts` file per `data-strategy`; a data-driven `for...of` loop sits inside `describe`, outside `test()`.
6. If the test mutates state, add the cleanup hook per `references/destructive-tests.md`; API setup or teardown shared by several specs goes through `api-testing`.
7. Run `npx playwright test <file>` and `npm run lint`; on red, load `debugging`.

## References

- `references/spec-patterns.md`: skeletons for a functional, data-driven, E2E and setup spec.
- `references/tags.md`: what each tag covers, how each suite runs, the three tagging mistakes.
- `references/destructive-tests.md`: the shared-state definition, the cleanup pattern, the destructive suite, suite-only failures.

Files in this skill

  • SKILL.md15.4 KB
  • references/examples.md4.2 KB
  • references/troubleshooting.md2.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.