Skip to content

Configure Vitest to clear mocks automatically#66

Closed
kentcdodds wants to merge 1 commit intomainfrom
cursor/vitest-automatic-mock-clearing-144b
Closed

Configure Vitest to clear mocks automatically#66
kentcdodds wants to merge 1 commit intomainfrom
cursor/vitest-automatic-mock-clearing-144b

Conversation

@kentcdodds
Copy link
Copy Markdown
Member

Summary

  • add Vitest as a dev dependency and expose a dedicated bun run test:vitest script
  • add vitest.config.ts with clearMocks: true and scoped file discovery
  • add a focused proof test showing mock call history is reset between tests

Testing

  • bun run test:vitest
  • bunx prettier --check package.json vitest.config.ts vitest-tests/automatic-mock-clearing.test.ts
  • bun run lint package.json vitest.config.ts vitest-tests/automatic-mock-clearing.test.ts
Open in Web Open in Cursor 

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kentcdodds kentcdodds closed this Apr 2, 2026
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.

2 participants