-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Description
Describe the bug
When trying to spy on Prisma client methods, vitest throws the following error:
const prisma = new PrismaClient();
const spy = vitest.spyOn(prisma.user, 'findMany')Error: vi.spyOn() can only spy on a function. Received undefined.This setup works as expected in vitest v3, but no longer seems to behave work in vitest v4 versions.
This can be verified by installing vitest@3 in the reproduction repository and running the tests again.
Reproduction
https://github.com/schoero/repro-vitest-prisma-spies
System Info
System:
OS: macOS 15.7.3
CPU: (8) arm64 Apple M2
Memory: 107.09 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.5.0 - /Users/schoero/.volta/tools/image/node/24.5.0/bin/node
Yarn: 1.22.22 - /Users/schoero/.volta/tools/image/yarn/1.22.22/bin/yarn
npm: 11.5.1 - /Users/schoero/.volta/tools/image/node/24.5.0/bin/npm
pnpm: 10.16.0 - /Users/schoero/.volta/bin/pnpm
bun: 1.3.5 - /opt/homebrew/bin/bun
Browsers:
Chrome: 143.0.7499.194
Firefox: 142.0
Safari: 26.2
npmPackages:
vitest: ^4.0.17 => 4.0.17Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Type
Projects
Status
Approved