Describe the bug
The getMockImplementation() method only returns permanent implementations, not implementations only added once. So the return value of getMockImplementation() can be different, than the implementation being called.
To me, it would make sense, that this method always returns the implementation, that will be called on the next call.
Reproduction
const fn = vi.fn();
fn.mockReturnValueOnce('foo');
const mockImpl = fn.getMockImplementation(); // This returns undefined
System Info
Binaries:
Node: 20.15.1
npm: 10.9.0
npmPackages:
vite: ^5.4.6 => 5.4.6
vitest: ^2.1.1 => 2.1.1
Used Package Manager
npm
Validations
Describe the bug
The
getMockImplementation()method only returns permanent implementations, not implementations only added once. So the return value ofgetMockImplementation()can be different, than the implementation being called.To me, it would make sense, that this method always returns the implementation, that will be called on the next call.
Reproduction
System Info
Binaries: Node: 20.15.1 npm: 10.9.0 npmPackages: vite: ^5.4.6 => 5.4.6 vitest: ^2.1.1 => 2.1.1Used Package Manager
npm
Validations