-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: stop awaiting act() #7152
Conversation
// FIXME: the await triggers the warning | ||
// "Do not await the result of calling act(...) with sync logic, it is not a Promise." | ||
// but removing the await makes the test for describeParameters fail. | ||
await act(() => { | ||
rendered = render({ | ||
item, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Luckily in this case the ItemSearchTool component accepts an afterLoad callback, so we can use it to wait on.
Something like this should work:
let renderPromise: Promise<void> | undefined;
act(() => {
renderPromise = new Promise((resolve) => render({
item,
itemSearchProvider,
viewState,
afterLoad: resolve
}));
});
await renderPromise;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a commit with the suggestion and the tests now pass, thanks!
@pjonsson - thanks as always for your PRs, I have added a suggestion to fix the ItemSearchProviderSpec. |
This fixes the warning: Do not await the result of calling act(...) with sync logic, it is not a Promise.
a5ef58d
to
c0a31d7
Compare
Use the suggested fix from the code review to remove the final await on act.
c0a31d7
to
9952ae5
Compare
As a beginner it's hard to know where to look because of all the warnings (and easy to miss something essential). I'm guessing this PR falls somewhere between trivial and requires testing/effort, but it would be nice if the trivial stuff like #7134, #7136, and TerriaJS/terriajs-server#158 could get merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, merging.
What this PR does
This fixes the warning:
Do not await the result of calling act(...) with sync logic, it is not a Promise.
Test me
Tests only update.
Checklist
doc/
.