test(fonts): mock google font files in unit tests - #2412
Merged
james-elicx merged 1 commit intoJun 29, 2026
Merged
Conversation
The font self-hosting unit tests depended on live Google Fonts CSS and font file requests. When the CSS fetch hit a recoverable network error, the plugin correctly skipped _vinext injection for offline fallback, but the test expected self-hosted output. Mock both fonts.googleapis.com CSS and fonts.gstatic.com font binaries for the self-hosting assertions. The offline fallback behavior remains covered by the explicit network-error test.
commit: |
Contributor
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
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.
Fixes #2411
Overview
The Google font self-hosting unit tests now mock both the CSS request to
fonts.googleapis.comand the font binary request tofonts.gstatic.com.Why
The flaky CI failure was a real test isolation bug. The plugin intentionally treats raw Google Fonts fetch failures as recoverable offline behavior and skips
_vinext.fontinjection, but this unit test expected deterministic self-hosted output while relying on external network availability.What changed
.woff2responses in the self-hosting transform test..woff2cache output without external network.Validation
for i in 1 2 3 4 5; do vp test run tests/font-google.test.ts || exit $?; donevp check tests/font-google.test.tsNote: local pre-commit was run and its staged file check passed, but its broad repo check failed in this fresh worktree because
packages/vinext/node_modules/react-domwas not linked. The targeted checks above passed against the changed file.