replace usages of await act(async () => {}) with waitFor
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-react';
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { renderHook, waitFor } from '@testing-library/react';
|
||||
import React, { PropsWithChildren } from 'react';
|
||||
import { WebsiteListResponse } from '@backstage/plugin-lighthouse-common';
|
||||
import { lighthouseApiRef } from '../api';
|
||||
@@ -78,8 +78,9 @@ describe('useWebsiteForEntity', () => {
|
||||
|
||||
it('returns the lighthouse information for the website url in annotations', async () => {
|
||||
const { result } = subject();
|
||||
await act(async () => {});
|
||||
expect(result.current?.value).toBe(website);
|
||||
await waitFor(() => {
|
||||
expect(result.current?.value).toBe(website);
|
||||
});
|
||||
});
|
||||
|
||||
describe('where there is an error', () => {
|
||||
@@ -93,9 +94,10 @@ describe('useWebsiteForEntity', () => {
|
||||
|
||||
it('posts the error to the error api and returns the error to the caller', async () => {
|
||||
const { result } = subject();
|
||||
await act(async () => {});
|
||||
expect(result.current?.error).toBe(error);
|
||||
expect(mockErrorApi.post).toHaveBeenCalledWith(error);
|
||||
await waitFor(() => {
|
||||
expect(result.current?.error).toBe(error);
|
||||
expect(mockErrorApi.post).toHaveBeenCalledWith(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -110,9 +112,10 @@ describe('useWebsiteForEntity', () => {
|
||||
|
||||
it('does not post the error to the error api and returns the error to the caller', async () => {
|
||||
const { result } = subject();
|
||||
await act(async () => {});
|
||||
expect(result.current?.error).toBe(error);
|
||||
expect(mockErrorApi.post).not.toHaveBeenCalledWith(error);
|
||||
await waitFor(() => {
|
||||
expect(result.current?.error).toBe(error);
|
||||
expect(mockErrorApi.post).not.toHaveBeenCalledWith(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user