Context
The review rounds on #5209 highlighted a gap: repo scripts (e.g. packages/eds-tokens/scripts/*.mjs) often run unattended — the Tokens Studio release workflow has no CI on its PRs — so an embedded runtime guard is frequently the only automated check. Runtime guards protect the output against bad input, but nothing protects the scripts against regressions when they are edited later. The NaN-threshold bug found in review (a non-numeric argument silently disabled the guard's checks) is exactly the class of bug a unit test catches immediately.
Task
Establish the convention that new scripts containing logic must ship with tests, and document it in AGENTS.md (the canonical conventions file) so it applies to human and AI contributions alike.
Suggested shape of the convention:
- Applies to new scripts with branching/transformation logic under
packages/*/scripts/ and workflow-invoked tooling; trivial one-liner wrappers are exempt
- CLI-style scripts (top-level await, no exports) are tested by spawning them as child processes against fixtures in a temp directory — this also covers the CLI contract (arguments, exit codes, error messages) that workflows actually consume
- Use the package's existing test runner (vitest in eds-tokens, jest in eds-core-react)
- Precedent:
build-dark-scope in eds-tokens-build already has tests
Done when
- The convention is written into
AGENTS.md
- Tool-specific configs need no change (they reference
AGENTS.md)
Backfilling tests for existing untested scripts (e.g. generate-css-bundle.mjs, assert-no-light-dark.mjs, generate-ts-tokens.mjs) is deliberately not part of this task — split into separate issues as needed.
Context
The review rounds on #5209 highlighted a gap: repo scripts (e.g.
packages/eds-tokens/scripts/*.mjs) often run unattended — the Tokens Studio release workflow has no CI on its PRs — so an embedded runtime guard is frequently the only automated check. Runtime guards protect the output against bad input, but nothing protects the scripts against regressions when they are edited later. The NaN-threshold bug found in review (a non-numeric argument silently disabled the guard's checks) is exactly the class of bug a unit test catches immediately.Task
Establish the convention that new scripts containing logic must ship with tests, and document it in
AGENTS.md(the canonical conventions file) so it applies to human and AI contributions alike.Suggested shape of the convention:
packages/*/scripts/and workflow-invoked tooling; trivial one-liner wrappers are exemptbuild-dark-scopein eds-tokens-build already has testsDone when
AGENTS.mdAGENTS.md)Backfilling tests for existing untested scripts (e.g.
generate-css-bundle.mjs,assert-no-light-dark.mjs,generate-ts-tokens.mjs) is deliberately not part of this task — split into separate issues as needed.