You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
describe('App', () => {
test('renders App component', async () => {
render(<App />);
expect(screen.queryByText(/Signed in as/)).toBeNull();
screen.debug();
expect(await screen.findByText(/Signed in as/)).toBeInTheDocument();
screen.debug();
});
});
There is aways Warning:
console.error
Warning: An update to App inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at https://fb.me/react-wrap-tests-with-act
in App
I have googled for the reason and solution, but I have added await in the code.
Do you have any solutions please ?
The text was updated successfully, but these errors were encountered:
Hi Robin, I am learning RTL by reading your aritlce How to use React Testing Library Tutorial.
When I write this test example:
There is aways
Warning
:I have googled for the reason and solution, but I have added
await
in the code.Do you have any solutions please ?
The text was updated successfully, but these errors were encountered: