Skip to content

Instantly share code, notes, and snippets.

@BenBrostoff
Last active August 11, 2019 19:23
Show Gist options
  • Save BenBrostoff/1b13a6b1da5b3294864bd257f924480e to your computer and use it in GitHub Desktop.
Save BenBrostoff/1b13a6b1da5b3294864bd257f924480e to your computer and use it in GitHub Desktop.
Test async act
it('should render with the correct text with sync act', () => {
act(() => {
ReactDOM.render(<AsyncApp/>, el);
});
expect(el.innerHTML).toContain('unloaded val');
});
it('should render with the correct text with async act', async () => {
await act(async () => {
ReactDOM.render(<AsyncApp/>, el);
});
expect(el.innerHTML).toContain('fetched val');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment