Kesalahan: tidak diterapkan: window.alert


//How I solved this problem is actually define the window.alert method at the top of the test file as a jest spy. This should work for any window method (in my case I was actually testing window.open).

//Be sure to call mockClear() in your test, since this is a global object and it's calls will persist across tests.

window.alert = jest.fn();

test("login api resolves true", () => {
  window.alert.mockClear();
  /* ... */
})
DevPedrada