Repository navigation
perf(test): speed up unit tests by ~60% - #1137
Merged
Merged
Conversation
- Move createTestCommands out of testHelpers into test/mocks/commands.ts. testHelpers imported @/commands at runtime, so every extension test file loaded most of src/ (~450ms each). - Run the webview project on vmForks, ~70% faster for jsdom. The setup file's uncaughtException filter is removed per file, since vmForks shares process across files. The extension project stays on forks because vm contexts break instanceof Error for Node built-in values. - Replace `as unknown as CoderApi` casts with createTestCoderApi, a real CoderApi with typed overrides.
EhabY
force-pushed
the
perf/speed-up-unit-tests
branch
from
October 6, 2026 10:18
a292aa0 to
42cc406
Compare
EhabY
marked this pull request as ready for review
October 6, 2026 11:16
jakehwll
approved these changes
Oct 6, 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.
Cuts unit test time on CI by roughly 60% on every job. Test and config changes only.
src/.testHelpers.tsimported@/commandsat runtime for one helper (~450ms per file).createTestCommandsnow lives intest/mocks/commands.ts.vmForks(~70% faster for jsdom).test/webview/setup.tsremoves itsuncaughtExceptionfilter per file, sincevmForkssharesprocessacross files.as unknown as CoderApicasts withcreateTestCoderApi: a realCoderApiwith typed overrides. Five casts remain, each for the reason listed below.Duration)Investigation notes
Pools (local, 4 workers, before these changes):
forks(default)threadsvmForks/vmThreadsisolate: falsefsModuleCachevmForksThe extension project stays on
forks. In a vm context, values from Node built-ins (execFileerrors,AbortControllerreasons,fs.readdirarrays) are cross-realm, soinstanceof Error/toStrictEqualdiverge from Electron (isAbortError,toError,cliError).Remaining
as unknown as CoderApi:inbox(the stub doesn't match the real return type),authInterceptor(fakes internal state),deploymentManager×2 (CoderApi.createis mocked),workspacesProvider(class mock;Object.assigncan't copy prototype methods).Windows ARM64 setup (~190–290s of pnpm cache restore + install) is unchanged. The image has no fast
D:drive and Defender real-time protection is on. Temporary side-by-side jobs, 3 runs each, median job total: baseline 257s, Defender off 302s,verifyStoreIntegrity=false286s, both 314s. Single runs: no cache 349s, Dev Drive 613s. None beat runner noise (baseline alone ranged 249–318s).Generated by Coder Agents on behalf of @EhabY.