Skip to content

New Rule: Prefer mock resolved/rejected shorthands #104

@alexilyaev

Description

@alexilyaev

Simple sugar function for:

jest.fn().mockReturnValue(Promise.resolve(value));

Useful to mock async functions in async tests:

test('async test', async () => {
  const asyncMock = jest.fn().mockResolvedValue(43);

  await asyncMock(); // 43
});

Refs:

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