test: snapshot generated files instead of matching fragments - #26
Merged
Merged
Conversation
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
approved these changes
Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated output is deterministic, so the regression tests now compare whole generated files rather than stacking
toContain/toMatchchecks on fragments.expectGenerated([result.typesFile, …])(__tests__/generated-snapshot.ts) writes each file to__tests__/__snapshots__/<suite>/<test-name>/<file>.tswithtoMatchFileSnapshot, so a generator change shows up in review as a diff of real generated code.codegen-regressions,nullables(from its.snapfile, now deleted) andtypescript-hint. The two case-table tests usetest.for, one snapshot folder per case.Test code: 94 lines added, 492 removed, plus 44 snapshot files.
Whichever of this and #25 merges second needs
vitest -u. #25 changesRecord<string | number, …>toRecord<string, …>, which appears in several snapshots.