Skip to content

[unbound-method]: should ignore accessing jest.mocked().mock #1800

@SchroederSteffen

Description

@SchroederSteffen

I noticed that the unbound-method rule reports the following code:

const parameter = jest.mocked(service.method).mock.calls[0][0];

However, the following variant is not reported:

const mockedMethod = jest.mocked(service.method);
const parameter = mockedMethod.mock.calls[0][0];

Using any .mockXY() methods is also fine (as expected since #1596):

jest.mocked(service.method).mockReturnValue();
Image

Reproduction: https://github.com/SchroederSteffen/jest-eslint-unbound-method-repro/blob/main/src/service.spec.ts

I think the mentioned case should NOT report an error.

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