Select: use findBy and make these tests async to avoid act() errors (#42134)

This commit is contained in:
Ashley Harrison 2021-11-23 14:53:10 +00:00 committed by GitHub
parent d2d38c978f
commit 20e1457a78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -13,11 +13,11 @@ jest.mock('@grafana/runtime', () => ({
}));
describe('TeamPicker', () => {
it('renders correctly', () => {
it('renders correctly', async () => {
const props = {
onSelected: () => {},
};
render(<TeamPicker {...props} />);
expect(screen.getByTestId('teamPicker')).toBeInTheDocument();
expect(await screen.findByTestId('teamPicker')).toBeInTheDocument();
});
});

View File

@ -35,11 +35,11 @@ const setupTestContext = (options: Partial<Props>) => {
describe('General Settings', () => {
describe('when component is mounted with timezone', () => {
it('should render correctly', () => {
it('should render correctly', async () => {
setupTestContext({});
screen.getByDisplayValue('test dashboard title');
screen.getByDisplayValue('test dashboard description');
expect(screen.getByTestId(selectors.components.TimeZonePicker.containerV2)).toHaveTextContent(
expect(await screen.findByTestId(selectors.components.TimeZonePicker.containerV2)).toHaveTextContent(
'Coordinated Universal Time'
);
});