Skip to content

mockRejectedValue causes unhandled rejection #5721

Closed
@javinor

Description

@javinor

Do you want to request a feature or report a bug?

bug - I opened a PR to fix this

What is the current behavior?

Using mockFn.mockRejectedValue(value) causes a misleading unhandled rejection. This doesn't happen when using an equivalent mockFn.mockImplementation(fn), and is not immediately obvious why this happens.

If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.

https://github.com/javinor/mock-rejected-value-causes-unhandled-rejection

What is the expected behavior?

To not throw an unhandled rejection

Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.

Jest 22.4
Node v9.7.1
Mac OSX

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions