Repository navigation
fix(test): upgrade vitest to 4 and restore the suites it was silently skipping - #1317
Open
arkhindi12 wants to merge 1 commit into
Open
arkhindi12 wants to merge 1 commit into
arkhindi12 wants to merge 1 commit into
Conversation
Both workspaces declared vitest ^1.3.0 (resolving 1.6.1). Bump to ^4.1.12, which is the current major that still supports Node 20 — the version CI pins. `npm run test:vitest` was already broken on main in both workspaces before this change: it collected zero tests and reported 37 failures in sdk and 107 in wallet. Three causes: - No `include`, so vitest swept up the Jest suites and the Playwright spec and failed on `describe is not defined`. - sdk ran with `environment: node` while its suites touch localStorage and document. - wallet used `provider: 'v8'` without depending on @vitest/coverage-v8. Also: tests/ was claimed by both runners. The suites call `jest.mock`, which only Jest hoists, so under vitest they silently exercised the real modules instead of the mocks. tests/ is now Vitest-only in both workspaces and the Jest testMatch no longer lists it; the files moved to `vi.mock`/`vi.fn`. One real bug surfaced: the WebAuthn suite replaced the whole `crypto` object with just `getRandomValues`, dropping `subtle`, which the code under test needs to import an ECDSA P-256 key. The mock now keeps the real `subtle`. CI never ran `npm run test:vitest`, which is how it stayed broken without anyone noticing. Both jobs now run it after Jest. Test counts (suites / tests), unchanged in total: sdk before 36 / 434 -> after 33 / 420 (jest) + 3 / 14 (vitest) wallet before 101 / 1555 -> after 98 / 1511 (jest) + 3 / 44 (vitest) No suite is skipped or marked todo to get there; the 2 skipped suites and 3 skipped tests in wallet are the pre-existing `live`-gated ones. Coverage reporting works in both. `@stellar/stellar-sdk` is untouched (see Miracle656#660).
|
@arkhindi12 is attempting to deploy a commit to the miracle656's projects Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
What this does
Bumps
vitestinsdkandfrontend/walletfrom^1.3.0(resolving 1.6.1) to^4.1.12, the current major that still supports Node 20 — the version CI pins. Both workspaces end up on the same major.Closes #1311
The suites were already broken, not just stale
Worth stating up front, because it changes what this PR is:
npm run test:vitestdid not work onmainin either workspace. It collected zero tests and reported every file as failed.Three causes, all fixed here:
include. Vitest swept up the Jest suites and the Playwright spec, then failed ondescribe is not defined. Both configs now scope totests/**/*.test.ts.environment: 'node'while the suites touchlocalStorageanddocument. Nowjsdom.@vitest/coverage-v8while its config already asked forprovider: 'v8'. Added.The
@veil/*aliases that only existed in Jest'smoduleNameMapperare now mirrored intoresolve.alias, so the suites resolve the same way under both runners.tests/ was being run twice, with different semantics
Both runners claimed
tests/. Those suites calljest.mock, which only Jest hoists — so under Vitest the mocks were silently inert and the tests exercised the real modules instead. That is a passing-looking test that tests nothing, which is the same failure mode this issue warns about.tests/is now Vitest-only in both workspaces, and Jest'stestMatchno longer lists it. The affected files moved fromjest.mock/jest.fntovi.mock/vi.fn. This is the "fix the suites rather than pin around them" part of the issue.One real bug surfaced
The WebAuthn suite replaced the whole
cryptoobject with justgetRandomValues:That dropped
subtle, which the code under test needs to import an ECDSA P-256 key — it failed withCannot read properties of undefined (reading 'importKey'). The mock now keeps the realsubtle.Test counts
Suites / tests, before → after. Totals are unchanged; the split just moved because
tests/changed owner.No suite is skipped or marked todo to reach these numbers. The 2 skipped suites and 3 skipped tests in wallet are the pre-existing
live-gated ones (drift.live.test.ts,sponsoredSubmit.live.test.ts), untouched.Measured on
main(baseline) and on this branch, same machine, Node 22:Coverage
Works in both, and both exit 0. The previous
thresholds: 70was carried over from the Jest run, which measures all ofsrc/; applying it to the three-file Vitest subset made the command fail permanently, which is how it stayed unrun. The floor is now set to what those suites actually cover (sdk 14/8/18/15, wallet 30/15/30/30) with a comment explaining the distinction — coverage still reports, it just no longer claims 70% of a subset. Say the word if you'd rather keep 70 and gate on the Jest run only.CI
Neither job ran
npm run test:vitest, which is precisely how this rotted unnoticed. Both now run it right after Jest.Out of scope
@stellar/stellar-sdkis untouched — no version or declaration change in either lockfile (verified by diffing the@stellarentries). Version spread stays with #660.Verification
ci.ymlstill parses; all 10 jobs intact.