diff --git a/superset-frontend/src/components/FaveStar/FaveStar.test.tsx b/superset-frontend/src/components/FaveStar/FaveStar.test.tsx
index 68433db96ea4e..ab2fa9fa0ed1e 100644
--- a/superset-frontend/src/components/FaveStar/FaveStar.test.tsx
+++ b/superset-frontend/src/components/FaveStar/FaveStar.test.tsx
@@ -26,13 +26,13 @@ jest.mock('src/components/Tooltip', () => ({
Tooltip: (props: any) =>
,
}));
-test('render right content', () => {
+test('render right content', async () => {
const props = {
itemId: 3,
saveFaveStar: jest.fn(),
};
- const { rerender } = render();
+ const { rerender, findByRole } = render();
expect(screen.getByRole('button')).toBeInTheDocument();
expect(
screen.getByRole('img', { name: 'favorite-selected' }),
@@ -45,7 +45,7 @@ test('render right content', () => {
rerender();
expect(
- screen.getByRole('img', { name: 'favorite-unselected' }),
+ await findByRole('img', { name: 'favorite-unselected' }),
).toBeInTheDocument();
expect(props.saveFaveStar).toBeCalledTimes(1);
@@ -54,7 +54,7 @@ test('render right content', () => {
expect(props.saveFaveStar).toBeCalledWith(props.itemId, false);
});
-test('render content on tooltip', () => {
+test('render content on tooltip', async () => {
const props = {
itemId: 3,
showTooltip: true,
@@ -63,7 +63,7 @@ test('render content on tooltip', () => {
render();
- expect(screen.getByTestId('tooltip')).toBeInTheDocument();
+ expect(await screen.findByTestId('tooltip')).toBeInTheDocument();
expect(screen.getByTestId('tooltip')).toHaveAttribute(
'id',
'fave-unfave-tooltip',
@@ -75,7 +75,7 @@ test('render content on tooltip', () => {
expect(screen.getByRole('button')).toBeInTheDocument();
});
-test('Call fetchFaveStar only on the first render', () => {
+test('Call fetchFaveStar only on the first render', async () => {
const props = {
itemId: 3,
fetchFaveStar: jest.fn(),
@@ -84,7 +84,10 @@ test('Call fetchFaveStar only on the first render', () => {
showTooltip: false,
};
- const { rerender } = render();
+ const { rerender, findByRole } = render();
+ expect(
+ await findByRole('img', { name: 'favorite-unselected' }),
+ ).toBeInTheDocument();
expect(props.fetchFaveStar).toBeCalledTimes(1);
expect(props.fetchFaveStar).toBeCalledWith(props.itemId);