You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
expect.toHaveReturned does not return true when a mock function is updated to return value
Reproduction
Code:
import{expect,test,vi}from"vitest";test("toHaveReturned",()=>{constmockError=newError("mockError");constmockFn=vi.fn(()=>{throwmockError;});try{mockFn();}catch(error){}expect(mockFn).not.toHaveReturned();constmockReturn=42;mockFn.mockReturnValue(mockReturn);constmockOutput=mockFn();expect(mockOutput).toBe(mockReturn);expect(mockFn).toHaveReturned();// <-- This should be true.});
Output:
AssertionError: expected "spy" to be successfully called at least once ❯ src/__fixtures__/expect/toHaveReturned.output.js:15:18 13| const mockOutput = mockFn(); 14| expect(mockOutput).toBe(mockReturn); 15| expect(mockFn).toHaveReturned(); | ^ 16| }); - Expected "false" + Received "true"
Describe the bug
expect.toHaveReturned does not return true when a mock function is updated to return value
Reproduction
Code:
Output:
System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: