Skip to content
Back to skills

Data Strategy

ASecurity

Use when creating or extending a data factory, adding a static set of invalid or boundary values, or deciding whether a test value is generated, static, inline or an enum. Not for editing an existing static value (see `refactor-values`) or the loop that consumes a set (see `test-standards`).

  • 312 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 22, 2026
testingtypescriptgoapi

Works with

  • api

Security analysis

A100/100

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

Scanned November 29, 2026

npx -y skills add idavidov13/agentic-playwright --skill data-strategy --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Data Strategy?

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

Security grade badge for Data Strategy
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/idavidov13-data-strategy/badge)](https://www.skillsdirectory.com/skills/idavidov13-data-strategy)

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: data-strategy
description: Use when creating or extending a data factory, adding a static set of invalid or boundary values, or deciding whether a test value is generated, static, inline or an enum. Not for editing an existing static value (see `refactor-values`) or the loop that consumes a set (see `test-standards`).
---

# Data Strategy

## Critical

- Every file under `test-data/static/**` is `.ts` exporting `as const` literal values: never `.json`, no runtime import, no function, no computed value, no Faker call (the Constitution checks reject anything else).

    ```typescript
    // CORRECT
    export const INVALID_EMAILS = ['', 'plaintext', 'missing@domain'] as const;
    // WRONG
    export const INVALID_EMAILS = [faker.internet.email(), buildBadEmail()];
    ```

- Never hardcode test content strings (names, emails, descriptions, product names) in a spec or page object; generate them with a Faker factory from `test-data/factories/{area}/`.

    ```typescript
    // CORRECT
    const product = generateProduct();
    // WRONG
    const product = { name: 'Test Product 1', price: 9.99 };
    ```

- Never redefine the universal type-mismatch arrays inline; import `INVALID_STRING_VALUES`, `INVALID_NUMBER_VALUES`, `INVALID_BOOLEAN_VALUES`, `INVALID_UUID_VALUES`, `INVALID_ENUM_VALUES`, `INVALID_ARRAY_VALUES` and `INVALID_OBJECT_VALUES` from `test-data/static/util/invalid-values.ts`.
- A factory merges `overrides` over Faker defaults, returns `Schema.parse(merged)` and carries the Zod-inferred return type; never a cast.
- Never Faker-generate an app-defined string (error message, label, heading, route): it is the app's text, captured live; messages and routes come from `enums/{area}/*` (`enums`).
- A value used in exactly one assertion stays inline in the test; a static file holds a curated set that a loop iterates.
- Editing an existing static value or enum member goes through `refactor-values` first.
- No magic numbers inline (timeouts, retry counts, limits): suite tuning in `playwright.config.ts` (`config`), domain limits in `enums/{area}/*`, a per-assertion `{ timeout }` only with a comment saying why.

## Procedure

1. Classify the value; `ls test-data/static/` and `ls test-data/factories/` resolve `{area}`. App-defined strings go to `enums`, tuning numbers to `config`; anything that fits no row: stop and ask.

    | Value                                                        | Home                                                      |
    | ------------------------------------------------------------ | --------------------------------------------------------- |
    | Happy-path dynamic data (names, emails, ids, content)        | factory in `test-data/factories/{area}/<name>.factory.ts` |
    | Universal type-mismatch values                               | import from `test-data/static/util/invalid-values.ts`     |
    | Curated invalid or boundary set tied to the app's validation | `test-data/static/{area}/<name>.ts`                       |
    | Range violation for one field, used in one spec              | inline array in the spec                                  |

2. Factory: the schema must exist in `fixtures/api/schemas/{area}/` (`type-safety`); write it per `references/factories.md`.
3. Static set: pick the tier and the file shape per `references/static-data-tiers.md`; a set a second spec or field needs moves from inline to `test-data/static/{area}/`.
4. Consume: the factory call in the spec, fixture or page-object action; a static export through a `for...of` loop per `test-standards`. Run `npm run lint` and the affected tests.

## References

- `references/factories.md`: open when creating or extending a factory, pinning fields with overrides, or when `Schema.parse` throws inside one.
- `references/static-data-tiers.md`: open when adding a static set: the three tiers, the two file shapes, promotion from inline, collisions between parallel tests.

Files in this skill

  • SKILL.md13.3 KB
  • references/examples.md3.3 KB
  • references/troubleshooting.md1.8 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.