A callback of waitFor fires events, which it repeats every time it retries

tx0/ts:action-in-wait-fordefaultwarningreliability/concurrencydepth fastbug

What it finds

waitFor calls its callback again and again until it stops throwing. An event fired in it is fired on every attempt, so the test clicks or types more often than it says. Actions belong before waitFor, and only the check inside.

Reported are calls of fireEvent and user event methods inside the callback of waitFor.

From the rule's source, action_in_wait_for.rs.

Example from the rule's tests
declare const screen: any;declare const fireEvent: any;declare function waitFor(f: () => void): Promise<void>;it("opens", async () => {  await waitFor(() => {    fireEvent.click(screen.getByText("Open"));tx0 reports: this event is fired again every time  });});
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:action-in-wait-for" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:action-in-wait-for] reason="..."

tx0 explain tx0/ts:action-in-wait-for shows the same in the terminal. Found a false positive? Report it.