Skip to content

lodash/prefer-* rules cause problems with Jest mocks #340

@jamesarosen

Description

@jamesarosen

The lodash/prefer-* rules, notably lodash/prefer-noop, cause issues with Jest Mocks.

For example:

import noop from 'lodash/noop'

jest.mock('./widget', () => ({
  __esModule: true,
  default: noop,
}))

This causes the error

The module factory of “jest.mock()” is not allowed to reference any out-of-scope variables.

The problem is that jest.mock can't reference the imported noop.

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