Skip to content

Conversation

@fabiovincenzi
Copy link
Contributor

@fabiovincenzi fabiovincenzi commented Feb 2, 2026

Fixes: #1362.
Make tests independent of execution order so they pass with --sequence.shuffle. The root causes were shared mutable state across tests running in a single process: DB records, mock leaks, module cache, network ports, and filesystem artifacts.

  • Fix fire-and-forget async operations in production code:
    • clearBareClone.ts: fs.rm() with callback was not awaited, causing race conditions. Switched to await fs.promises.rm().
    • Proxy.start(): server.listen() was not awaited and errors were silently ignored. Wrapped in a Promise with proper error handling.
    • Service.stop(): _httpServer was not reset to null after close, preventing clean restarts.
    • repo.ts POST route: proxy restart happened after res.send(), so clients received 200 before the proxy was ready. Moved restart before the response, consistent with the DELETE route.
  • Fix mock/spy leaks between tests:
    • extractRawBody.test.ts: moved mockClear() from afterAll to beforeEach.
    • testAuthMethods.test.ts: added vi.doUnmock('fs') before vi.resetModules() since doMock persists across module resets.
    • preReceive.test.ts: replaced vi.restoreAllMocks() with vi.clearAllMocks() to preserve module-level spies.
    • 1.test.ts: added vi.resetModules() before vi.doMock to ensure fresh imports.
    • proxy.test.ts: added missing on() method to mock HTTP servers.
  • Make each test self-contained (no implicit ordering dependencies):
    • testDb.test.ts: each test now creates its own prerequisites and cleans up conflicting state.
    • testLogin.test.ts: extracted loginAsAdmin() helper so each test gets its own session cookie.
    • testRepoApi.test.ts: moved login to beforeAll, added ensureTestRepoExists() helper, proper cleanup with proxy.stop() and Service.stop().
    • testProxyRoute.test.ts: each test ensures its own DB prerequisites exist.
  • Fix filesystem state dependencies:
    • ConfigLoader.test.ts: clean cached git clone directory before test to force git clone over git pull.
    • getDiff.test.ts: each test creates its own git commits with unique filenames.

@github-actions github-actions bot added the fix label Feb 2, 2026
@netlify
Copy link

netlify bot commented Feb 2, 2026

Deploy Preview for endearing-brigadeiros-63f9d0 ready!

Name Link
🔨 Latest commit 24fa182
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/6980ac699fc2a7000829a3ec
😎 Deploy Preview https://deploy-preview-1378.git-proxy.preview.finos.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

❌ Patch coverage is 87.83784% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.43%. Comparing base (4a21364) to head (24fa182).

Files with missing lines Patch % Lines
src/service/index.ts 76.19% 5 Missing ⚠️
src/proxy/index.ts 90.90% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1378      +/-   ##
==========================================
+ Coverage   80.40%   81.43%   +1.03%     
==========================================
  Files          65       65              
  Lines        4608     4644      +36     
  Branches      775      791      +16     
==========================================
+ Hits         3705     3782      +77     
+ Misses        888      847      -41     
  Partials       15       15              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests fail when shuffling test execution

1 participant