Mocking implementation of function returning a PromiseLike object partially work
Describe the bug
My use case is trying to mock a function returning a ResultAsync object from the neverthrow library. The ResultAsync object is an implementation of a PromiseLike interface which adds a few methods to the objects to help processing them. When mocking the implementation via vi.spyOn().mockImplementation() it seems that I can still await the promises as expected but I cannot use the additional methods without getting a TypeError.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-fdcijn?file=test/spy.test.ts
System Info
❯ npx envinfo --system --npmPackages '{vitest,vite,@vitejs/*}' --binaries --browsers
success Install finished in 0.977s
System:
OS: Linux 5.0 undefined
CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.10 - /bin/yarn
npm: 7.17.0 - /bin/npm
npmPackages:
vitest: ^0.21.1 => 0.21.1
Used Package Manager
npm
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
I think this is the same reason with #1767
Good catch that's likely the case :+1:
Issue appears to be fixed in 0.25.3 (not sure exactly which specific version did fix it though).