Skip to content

test: preserve utils UUID mock across resets - #10907

Draft
cryptodev-2s wants to merge 1 commit into
mainfrom
test/utils-uuid-mock-reset
Draft

cryptodev-2s wants to merge 1 commit into
mainfrom
test/utils-uuid-mock-reset

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

The utils UUID mock uses vi.fn().mockImplementation(actual.v4). With the shared mockReset: true setting, Vitest resets that mock to return undefined. Calling createSandbox() inside a test without overriding the UUID then throws when constructing the directory path.

Pass the real implementation directly to vi.fn(actual.v4) so mock resets restore it. A MockedFunction assertion preserves UUID's overloaded signatures. Add a regression test that creates two sandboxes without overriding UUID and checks that their directories differ; this test fails before the fix and passes afterward.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Test-only changes to Vitest mocking in fs.test.ts; no production code paths affected.

Overview
Fixes the uuid v4 mock in fs.test.ts so Vitest’s mockReset behavior does not leave v4 returning undefined after a reset. The mock now uses vi.fn(actual.v4) with a MockedFunction cast instead of mockImplementation, so resets restore the real UUID generator.

Adds a createSandbox regression test that creates two sandboxes without stubbing v4 and asserts their directoryPath values differ (fails under the old mock setup).

Reviewed by Cursor Bugbot for commit c0f1f17. Bugbot is set up for automated code reviews on this repo. Configure here.

@cryptodev-2s
cryptodev-2s requested a review from a team as a code owner October 20, 2026 10:29
@cryptodev-2s
cryptodev-2s deployed to default-branch October 20, 2026 10:29 — with GitHub Actions Active
@cryptodev-2s
cryptodev-2s marked this pull request as draft October 20, 2026 10:31

This branch was successfully deployed

1 active deployment
default-branch — c0f1f172 Deployed Oct 20, 2026 by cryptodev-2s via Determine whether this PR is a release PR #5688
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant