Closed
Description
react-testing-library
version: @testing-library/react@8.0.1react
version: react@16.8.1node
version: node@10.11.0npm
(oryarn
) version: npm@6.9.0
Relevant code or config:
import {wait} from '@testing-library/react';
describe('simple await', ()=> {
it('returns straight away', async ()=> {
await wait();
});
});
What you did:
I was trying to implement an await for an expectation to pass and the test kept failing due to timeout. I whittled the code down in order to find the cause and found that even a simple await wait();
would never return.
What happened:
The jest test would simply timeout without returning
Reproduction:
Problem description:
The problem seems to be with the waitWrapper
code in wait.js
in the @testing-library/dom
library. The asyncWrapper awaits on a promise but the inner code doesn't seem to return the promise:
function waitWrapper(...args) {
return (0, _config.getConfig)().asyncWrapper(() => wait(...args));
}
Suggested solution:
I was able to solve it by changing the above code to:
function waitWrapper(...args) {
return (0, _config.getConfig)().asyncWrapper(() => {
return wait(...args);
});
}
Metadata
Metadata
Assignees
Labels
No labels