Skip to content

test: snapshot generated files instead of matching fragments - #26

Merged
maxholman[bot] merged 1 commit into
masterfrom
test/file-snapshots
Sep 27, 2026
Merged

maxholman[bot] merged 1 commit into
masterfrom
test/file-snapshots

Conversation

@maxholman

@maxholman maxholman Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Generated output is deterministic, so the regression tests now compare whole generated files rather than stacking toContain/toMatch checks on fragments.

  • expectGenerated([result.typesFile, …]) (__tests__/generated-snapshot.ts) writes each file to __tests__/__snapshots__/<suite>/<test-name>/<file>.ts with toMatchFileSnapshot, so a generator change shows up in review as a diff of real generated code.
  • Converted: codegen-regressions, nullables (from its .snap file, now deleted) and typescript-hint. The two case-table tests use test.for, one snapshot folder per case.
  • The snapshot folder is ignored by oxlint and oxfmt and excluded from the fixture typecheck. It's compared byte for byte, and a formatter rewriting it would break the match.
  • Runtime and behaviour tests (test1, query round-trip, manifest, lint directives, etc.) are unchanged.

Test code: 94 lines added, 492 removed, plus 44 snapshot files.

Whichever of this and #25 merges second needs vitest -u. #25 changes Record<string | number, …> to Record<string, …>, which appears in several snapshots.

Codegen output is deterministic, so each regression test now writes the
files it covers to __tests__/__snapshots__/<suite>/<test>/ with
toMatchFileSnapshot and the fragment assertions go. The nullables .snap
entries move to the same layout. The snapshot folder is excluded from
oxlint, oxfmt and the fixture typecheck, since it holds generator output
compared byte for byte.

Co-Authored-By: LLM <noreply@block65.dev>
@maxholman
maxholman Bot merged commit e54874d into master Sep 27, 2026
4 checks passed
@maxholman
maxholman Bot deleted the test/file-snapshots branch September 27, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant