mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
fix: testing act error (#36915)
* test: switch act from react-dom/test-utils to testing-library/react * test: fix jest.runAllTimers usage with act Co-authored-by: ian.xufeng <ian.xufeng@shopee.com>
This commit is contained in:
parent
73e541911b
commit
20a2bb3374
@ -26,7 +26,7 @@ describe('Upload.Dragger', () => {
|
||||
},
|
||||
});
|
||||
|
||||
await act(() => {
|
||||
act(() => {
|
||||
jest.runAllTimers();
|
||||
});
|
||||
|
||||
|
@ -322,7 +322,9 @@ describe('Upload', () => {
|
||||
const { rerender } = render(<Upload ref={ref} />);
|
||||
expect(ref.current.fileList).toEqual([]);
|
||||
rerender(<Upload ref={ref} fileList={fileList} />);
|
||||
jest.runAllTimers();
|
||||
act(() => {
|
||||
jest.runAllTimers();
|
||||
});
|
||||
expect(ref.current.fileList).toEqual(fileList);
|
||||
jest.useRealTimers();
|
||||
});
|
||||
@ -725,7 +727,7 @@ describe('Upload', () => {
|
||||
await Promise.resolve();
|
||||
}
|
||||
});
|
||||
await act(() => {
|
||||
act(() => {
|
||||
jest.runAllTimers();
|
||||
});
|
||||
await act(async () => {
|
||||
@ -945,7 +947,7 @@ describe('Upload', () => {
|
||||
});
|
||||
|
||||
// Motion leave status change: start > active
|
||||
await act(() => {
|
||||
act(() => {
|
||||
jest.runAllTimers();
|
||||
});
|
||||
|
||||
|
@ -263,7 +263,7 @@ describe('Upload List', () => {
|
||||
// Error message
|
||||
fireEvent.mouseEnter(wrapper.querySelector('.ant-upload-list-item'));
|
||||
|
||||
await act(() => {
|
||||
act(() => {
|
||||
jest.runAllTimers();
|
||||
});
|
||||
|
||||
@ -574,7 +574,9 @@ describe('Upload List', () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
jest.runAllTimers();
|
||||
act(() => {
|
||||
jest.runAllTimers();
|
||||
});
|
||||
|
||||
unmount();
|
||||
|
||||
@ -1138,7 +1140,7 @@ describe('Upload List', () => {
|
||||
expect(onChange).toHaveBeenCalled();
|
||||
|
||||
// Check for images
|
||||
await act(() => {
|
||||
act(() => {
|
||||
jest.runAllTimers();
|
||||
});
|
||||
const afterImgNode = wrapper.container.querySelectorAll(
|
||||
@ -1313,7 +1315,7 @@ describe('Upload List', () => {
|
||||
|
||||
expect(uploadRef.current.fileList).toHaveLength(fileNames.length);
|
||||
|
||||
await act(() => {
|
||||
act(() => {
|
||||
jest.runAllTimers();
|
||||
});
|
||||
expect(uploadRef.current.fileList).toHaveLength(fileNames.length);
|
||||
|
@ -1,9 +1,8 @@
|
||||
import MockDate from 'mockdate';
|
||||
import type { ReactElement } from 'react';
|
||||
import { StrictMode } from 'react';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import type { RenderOptions } from '@testing-library/react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { render, act } from '@testing-library/react';
|
||||
import { _rs as onLibResize } from 'rc-resize-observer/lib/utils/observerUtil';
|
||||
import { _rs as onEsResize } from 'rc-resize-observer/es/utils/observerUtil';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user