Closed
Description
New waitFor
method added in dom-testing-library v7 introduces a new restriction on empty async utils: a callback must be passed as param. Empty callbacks are allowed but not recommended. Quoting changelog itself:
it's recommended to avoid an empty callback and instead insert an assertion in that callback function. This is because otherwise your test is relying on the "next tick of the event loop" before proceeding, and that's not consistent with the philosophy of the library:
Because of that, a new rule called no-wait-for-empty-cb
could enforce to pass non-empty callbacks to waitFor
.
What would be considered a non-empty callback tho? I would say any of these:
- empty arrow function (i.e.
() => {}
) - empty regular function (i.e.
function () {}
) - a var referencing any of previously mentioned
- a function or var called
noop
? - falsy values?