Open
Description
Jest hangs on the following sample test:
const { waitFor } = require("@testing-library/dom");
describe("test", () => {
it("test", async () => {
let value = 1;
setTimeout(() => {
value = 2;
});
await waitFor(() => {
// both these lines are important: it's necessary to do a mutation and to fail in the first iteration
// It works normally, if we comment one of these lines
document.body.setAttribute("data-something", 'whatever');
expect(value).toEqual(2);
});
console.log("execution never comes here");
});
});
Two conditions have to be met:
- there should be a DOM mutation in waitFor callback
- first execution of waitFor callback should fail
Expected result:
waitFor should resolve the promise after a successful iteration regardless whether there were DOM mutations or not
Current result:
waitFor calls the callback infinitely even if subsequent iterations don't throw any exception.
Environment:
@testing-library/[email protected]
[email protected]