Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix mockRejectedValue throwing error if not fulfilled on next tick #17258

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

gpfunk
Copy link

@gpfunk gpfunk commented Feb 11, 2025

What does this PR do?

This lets mockRejectedValue() and mockRejectedValueOnce() not throw errors if they're not fulfilled / resolved immediately after being set. This would match jest's implementation

To do this I switched up the logic so rather than returning a rejected promise, it returns a function that returns a rejected promise

Fixes #10437

I'm not that familiar with c++ or this codebase, so if theres a cleaner way to implement this please let me know! Thanks

  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

I wrote automated tests to ensure mocks that weren't called and fullfilled would not throw errors

@gpfunk gpfunk changed the title Allow mockRejectedValue to not throw error if not fulfilled immediately fix -- mockRejectedValue throwing error if not fulfilled on next tick Feb 11, 2025
@gpfunk gpfunk changed the title fix -- mockRejectedValue throwing error if not fulfilled on next tick fix mockRejectedValue throwing error if not fulfilled on next tick Feb 11, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bun test hangs and fails when mocking rejected promises and asserting with Supertest
1 participant