no-unsignaled-poll
Await the event a test depends on instead of polling spy or mock state until a deadline.
Why
Polling a spy races the code under test against the poll deadline: under CI load the call lands after the deadline and the test fails, and a negated call assertion passes before the call can happen.
Fix
Await the operation that makes the call, or have the test double resolve a promise when it is called and await that promise before asserting on the spy.
Examples
import { expect, it, vi } from "vitest";it("saves", async () => { const save = vi.fn(); submit(save); await vi.waitFor(() => expect(save).toHaveBeenCalledOnce());});import { expect, it, vi } from "vitest";it("saves", async () => { const called = Promise.withResolvers<void>(); const save = vi.fn(() => { called.resolve(); }); submit(save); await called.promise; expect(save).toHaveBeenCalledOnce();});import { expect, it, vi } from "vitest";it("saves", async () => { const save = vi.fn(); submit(save); await expect.poll(() => save.mock.calls.length).toBe(1);});import { expect, it, vi } from "vitest";it("saves", async () => { submit(); await vi.waitFor(() => expect(status()).toBe("saved"));});