'Jest async tests failing in test suite

My tests pass individually but fail as part of a test suite. I have tried jest.resetAllMocks() and jest.clearAllMocks() but has made no difference

const myMethodMock;

describe("my test suite", () => {
  beforeEach(() => {
    jest.resetAllMocks();
    jest.clearAllMocks();
  });


  it("should be successful", async () => {
    await myTestTarget();

    expect(myMethodMock).toHaveBeenCalled();
  });

//failing test
  it("should throw error", async () => {
    myMethodMock.mockRejectedValue(Error());

    await expect(() => myTestTarget())
      .rejects
      .toThrow("An error happened");
    expect(myTestTarget).toHaveBeenCalled();
  });
});


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source