Repository navigation
test: trim duplicate tests and cut suite run time - #87
Merged
Merged
Conversation
tRPC's isDev is true for every NODE_ENV but production, so the 100-200 ms per-call delay also ran under tests. It made up most of the suite's run time (azure-router 6 s, idp-policy 3 s, idp-router 2 s).
- cipher: the payload format test is implied by the pinned deterministic payload, since the IV is always zero. - tg-users-creation-history: idp-router already asserts the real policy of tg.users.getCreationHistory, including its scope. - azure-router: the stale-snapshot cases only made the mocked has() return false, the same path as the no-permission cases; the addMember check with member permissions repeats the matching it.each case.
Every test truncates all tables first, so the initial seed (~1.9 s) was thrown away; only the schema it migrated was needed (~0.3 s).
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 44 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Why
The suite took ~6.6 s locally (~15.6 s in CI). Most of that was waiting, not testing. A few tests also repeated coverage that other tests already provide.
Speed
src/trpc.ts: the timing middleware adds a 100–200 ms delay to every call when tRPC'sisDevis set.isDevis true for anyNODE_ENVexceptproduction, sotestgot the delay too. It now runs only whenenv.NODE_ENV === "development". Development and production behave as before.azure-router6.0 s → 0.26 s,idp-policy3.2 s → 3 ms,idp-router3.2 s → 1.2 s (what's left is the import of the app router).tests/seed-db.test.ts:beforeAlldid a full seed (~1.9 s), butbeforeEachtruncates every table right after. The tests only needed the migrated schema, sobeforeAllnow imports@/db, which applies the migrations (~0.3 s). This file is the slowest one in CI.Measured locally: the suite without the DB went from 6.6 s to 1.8 s, and
seed-dbfrom 14.6 s to 10.5 s (run-to-run noise included).Removed tests (each one checks something another test already covers)
cipher› has stable payload format: the IV is always zero, so the pinnedDETERMINISTIC_PAYLOADalready fixes the format.tg-users-creation-history› is limited to token callers…: this checked the policy through a mockeddashboard().idp-routerasserts the real policy oftg.users.getCreationHistory, including the scope andtokenOnly.azure-router› the two stale snapshot cases: they only made the mockedhas()return false. That is the same code path as the no permission cases, because nothing in the router readsstatus().azure-router› theaddMemberassertion with member permissions: the member permissions alone case of theit.eachmakes the same check with the same context.Checks
bun run typecheckandbiome cipassseed-dbrun against a fresh Postgres 18 on an empty schema