test: fix flaky tests and speed up slow test suite#242
Merged
anandgupta42 merged 1 commit intomainfrom Mar 18, 2026
Merged
Conversation
- Fix 4 failing tests: mock DuckDB driver in `adversarial.test.ts` and
`dbt-first-execution.test.ts`, use `describe.skipIf` with synchronous
`require.resolve("duckdb")` in `connections.test.ts`, add
`Fingerprint.reset()` to fix cross-test cache pollution in `skill.test.ts`
- Fix `registry.test.ts` timeout by replacing `cowsay` npm dep with local
module import and adding `git: true` fixture flag
- Fix flaky `pty-session.test.ts` by adding `retry: 2` for Bus event
delivery under parallel load
- Speed up `retry.test.ts` 28x (8.3s → 0.3s) by replacing 10s
`Bun.serve` idle timeout with raw TCP socket destroy
- Speed up `config.test.ts` 10x (7.1s → 0.7s) by mocking `BunProc.run`
to prevent real `bun install` during tests
- Speed up `tracing-adversarial.test.ts` 11x (5.7s → 0.5s) by replacing
5s exporter timeout with 200ms auto-resolve
- Speed up `project-scan.test.ts` 5x (16s → 3.2s) by caching
`detectDataTools`/`detectGit` results in `beforeAll`
- Speed up `oauth-browser.test.ts` 3.6x (6.4s → 1.8s) by reducing sleep
durations to match actual detection window timing
- Speed up 3 tracing snapshot/display tests 3-4x by reducing settle waits
from 200-500ms to 50-100ms
- Add `Fingerprint.reset()` export for test isolation (5 LOC production change)
- Result: 0 failures (was 4), 62s → 14s on targeted files, full suite stable
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude Code ReviewThis repository is configured for manual code reviews. 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.
What does this PR do?
Fixes 4 failing tests, eliminates flakiness, and speeds up the 9 slowest test files by 4.6x (62s → 14s).
Failures fixed (4 → 0):
adversarial.test.tsanddbt-first-execution.test.tsdescribe.skipIfwith synchronousrequire.resolve("duckdb")inconnections.test.tsFingerprint.reset()to fix cross-test cache pollution inskill.test.tscowsaynpm dep with local module inregistry.test.tsretry: 2for flaky PTY Bus event delivery under parallel loadSpeed improvements:
session/retry.test.tstracing-adversarial.test.tsconfig/config.test.tstool/project-scan.test.tstracing-adversarial-snapshot.test.tsmcp/oauth-browser.test.tstracing-display-crash.test.tstracing-adversarial-final.test.tstool/registry.test.tsProduction code change: Added
Fingerprint.reset()export (5 LOC) for test cache isolation.Type of change
Issue for this PR
Follow-up issue for tracing test consolidation: Closes #241
How did you verify your code works?
bun run typecheck)Checklist