Skip to content

jest.mock factory doesn't work inside a test #2582

Closed
@tleunen

Description

@tleunen

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

What is the current behavior?

It seems the way to create a mock with a factory doesn't work inside test or it. It works only when the mock is defined at the root level of the file.

Here's my example of a mock:

jest.mock('services/feature', () => ({
    isEnabled: () => true
}));

What is the expected behavior?

Mocking a file inside a test should work.

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

Jest 18.0.0, Node 7.4, macOS

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions