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
The test should pass as the function being called inside of the endpoint is being mocked to reject, and the Express route inside of the catch block sets the res.status to 400 and returns "Error".
What do you see instead?
The test hangs and the process doesn't complete:
Additional information
This style of tests works using Jest, I have been trying to convert an existing repo from Jest to bun test. if I change the spyOn to mock a different resolved value, the tests do not hang which makes me think it's related to the error being mocked or handling of errors.
The text was updated successfully, but these errors were encountered:
From what I can tell its related to whether the Promise is handled immediately
If I don't have the fn() call at all, it will fail in the way you've posted above
If I have some delay before calling the fn it will also fail in the way you've posted above
test.only("mockRejectedValue",async()=>{constfn=jest.fn();fn.mockRejectedValue(newError(42));awaitnewPromise(res=>setImmediate(res));// Fails with this line, passes without itawaitfn().catch(e=>null);// Fails if I don't have this line calling and handling the promise
What version of Bun is running?
1.1.4+fbe2fe0c3
What platform is your computer?
Darwin 23.4.0 arm64 arm
What steps can reproduce the bug?
When using an Express app and trying to test it with supertest, bun test hangs if a function within the tested express route is mocked to error:
What is the expected behavior?
The test should pass as the function being called inside of the endpoint is being mocked to reject, and the Express route inside of the catch block sets the res.status to 400 and returns "Error".
What do you see instead?
The test hangs and the process doesn't complete:

Additional information
This style of tests works using Jest, I have been trying to convert an existing repo from Jest to bun test. if I change the spyOn to mock a different resolved value, the tests do not hang which makes me think it's related to the error being mocked or handling of errors.
The text was updated successfully, but these errors were encountered: