From 5b1a48f75945dd0b8a8dac5ef3adbabc6c3910fb Mon Sep 17 00:00:00 2001 From: Dunqing Date: Sat, 20 May 2023 17:37:00 +0800 Subject: [PATCH 01/69] chore: migrate to vitest --- .../@rc-component/trigger.tsx | 11 +- .../copy-to-clipboard.ts | 0 {tests/__mocks__ => __mocks__}/rc-trigger.tsx | 9 +- .../lib => __mocks__/rc-util/es}/Portal.tsx | 6 +- __mocks__/rc-virtual-list.ts | 1 + .../__snapshots__/index.test.ts.snap | 12 +- .../__snapshots__/setup.test.tsx.snap | 4 +- components/__tests__/index.test.ts | 4 +- components/__tests__/node.test.tsx | 18 +- components/_util/__tests__/getScroll.test.ts | 8 +- .../__tests__/responsiveObserve.test.tsx | 2 +- components/_util/__tests__/scrollTo.test.ts | 12 +- components/_util/__tests__/util.test.tsx | 14 +- components/_util/__tests__/warning.test.ts | 8 +- components/_util/__tests__/wave.test.tsx | 12 +- components/affix/__tests__/Affix.test.tsx | 12 +- .../__snapshots__/Affix.test.tsx.snap | 4 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 6 +- components/alert/__tests__/index.test.tsx | 22 +- components/anchor/__tests__/Anchor.test.tsx | 69 +- .../__snapshots__/Anchor.test.tsx.snap | 8 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 6 +- components/app/__tests__/index.test.tsx | 6 +- .../__snapshots__/demo-extend.test.ts.snap | 8 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 4 +- .../auto-complete/__tests__/focus.test.tsx | 16 +- .../auto-complete/__tests__/index.test.tsx | 10 +- components/avatar/__tests__/Avatar.test.tsx | 8 +- .../__snapshots__/Avatar.test.tsx.snap | 32 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 4 +- components/back-top/__tests__/index.test.tsx | 12 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 28 +- .../__snapshots__/ribbon.test.tsx.snap | 4 +- components/badge/__tests__/index.test.tsx | 10 +- .../breadcrumb/__tests__/Breadcrumb.test.tsx | 8 +- .../__snapshots__/Breadcrumb.test.tsx.snap | 24 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/itemRender.test.tsx.snap | 4 +- .../__snapshots__/router.test.tsx.snap | 4 +- .../breadcrumb/__tests__/router.test.tsx | 8 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 52 +- .../button/__tests__/delay-timer.test.tsx | 8 +- components/button/__tests__/index.test.tsx | 22 +- components/button/__tests__/wave.test.tsx | 12 +- .../__snapshots__/demo-extend.test.ts.snap | 22 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 10 +- components/calendar/__tests__/index.test.tsx | 70 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 8 +- components/card/__tests__/index.test.tsx | 14 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 12 +- components/carousel/__tests__/index.test.tsx | 10 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 34 +- components/cascader/__tests__/index.test.tsx | 28 +- .../__snapshots__/checkbox.test.tsx.snap | 4 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/group.test.tsx.snap | 6 +- .../checkbox/__tests__/checkbox.test.tsx | 6 +- components/checkbox/__tests__/group.test.tsx | 24 +- .../__snapshots__/demo-extend.test.ts.snap | 4 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 8 +- components/collapse/__tests__/index.test.tsx | 18 +- .../__snapshots__/demo-extend.test.ts.snap | 22 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 8 +- .../__tests__/components.test.tsx | 14 +- .../color-picker/__tests__/index.test.tsx | 6 +- .../__snapshots__/components.test.tsx.snap | 808 +- .../__snapshots__/form.test.tsx.snap | 4 +- .../__snapshots__/popup.test.tsx.snap | 8 +- .../__tests__/components.test.tsx | 1 - .../__tests__/container.test.tsx | 10 +- .../config-provider/__tests__/form.test.tsx | 30 +- .../config-provider/__tests__/locale.test.tsx | 10 +- .../config-provider/__tests__/memo.test.tsx | 6 +- .../config-provider/__tests__/popup.test.tsx | 21 +- .../config-provider/__tests__/target.test.tsx | 18 +- .../config-provider/__tests__/theme.test.tsx | 10 +- .../__tests__/useConfig.test.tsx | 6 +- .../date-picker/__tests__/DatePicker.test.tsx | 30 +- .../__tests__/QuarterPicker.test.tsx | 2 +- .../__tests__/RangePicker.test.tsx | 6 +- .../__snapshots__/DatePicker.test.tsx.snap | 8 +- .../__snapshots__/QuarterPicker.test.tsx.snap | 4 +- .../__snapshots__/RangePicker.test.tsx.snap | 6 +- .../__snapshots__/WeekPicker.test.tsx.snap | 4 +- .../__snapshots__/demo-extend.test.ts.snap | 4 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/mount.test.ts.snap | 10 +- .../__snapshots__/other.test.tsx.snap | 14 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 18 +- .../descriptions/__tests__/index.test.tsx | 6 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- components/divider/__tests__/index.test.tsx | 4 +- components/drawer/__tests__/Drawer.test.tsx | 18 +- .../drawer/__tests__/DrawerEvent.test.tsx | 30 +- .../__snapshots__/Drawer.test.tsx.snap | 26 +- .../__snapshots__/DrawerEvent.test.tsx.snap | 4 +- .../__snapshots__/demo-extend.test.tsx.snap | 4049 ------- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../drawer/__tests__/demo-extend.test.tsx | 4 +- components/drawer/__tests__/type.test.tsx | 2 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../dropdown-button.test.tsx.snap | 6 +- .../__snapshots__/index.test.tsx.snap | 10 +- .../__tests__/dropdown-button.test.tsx | 38 +- components/dropdown/__tests__/index.test.tsx | 47 +- .../__snapshots__/demo-extend.test.ts.snap | 98 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 6 +- .../__snapshots__/back-top.test.tsx.snap | 4 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/group.test.tsx.snap | 4 +- .../__snapshots__/index.test.tsx.snap | 6 +- .../float-button/__tests__/back-top.test.tsx | 10 +- .../float-button/__tests__/group.test.tsx | 8 +- .../float-button/__tests__/index.test.tsx | 10 +- .../__snapshots__/demo-extend.test.ts.snap | 46 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 14 +- .../__snapshots__/list.test.tsx.snap | 4 +- components/form/__tests__/index.test.tsx | 58 +- .../form/__tests__/list-noStyle.test.tsx | 8 +- components/form/__tests__/list.test.tsx | 10 +- components/form/__tests__/ref.test.tsx | 6 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 14 +- components/grid/__tests__/gap.test.tsx | 4 +- components/grid/__tests__/index.test.tsx | 36 +- components/grid/__tests__/server.test.tsx | 2 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- components/icon/__tests__/index.test.tsx | 2 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 6 +- components/image/__tests__/index.test.tsx | 2 +- .../__snapshots__/demo-extend.test.ts.snap | 6 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 10 +- .../input-number/__tests__/index.test.tsx | 6 +- .../input-number/__tests__/prefix.test.tsx | 2 +- components/input/__tests__/Password.test.tsx | 28 +- components/input/__tests__/Search.test.tsx | 26 +- .../__snapshots__/Password.test.tsx.snap | 12 +- .../__snapshots__/Search.test.tsx.snap | 26 +- .../__snapshots__/index.test.tsx.snap | 146 +- .../__snapshots__/textarea.test.tsx.snap | 58 +- components/input/__tests__/focus.test.tsx | 8 +- components/input/__tests__/index.test.tsx | 10 +- components/input/__tests__/textarea.test.tsx | 53 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 14 +- .../__tests__/dynamic-breakpoint.test.tsx | 10 +- components/layout/__tests__/index.test.tsx | 16 +- components/layout/__tests__/warning.test.tsx | 2 +- .../__snapshots__/Item.test.tsx.snap | 10 +- .../__snapshots__/demo-extend.test.ts.snap | 33 +- .../__tests__/__snapshots__/demo.test.ts.snap | 33 +- .../__snapshots__/empty.test.tsx.snap | 4 +- .../__snapshots__/index.test.tsx.snap | 6 +- .../__snapshots__/pagination.test.tsx.snap | 14 +- components/list/__tests__/pagination.test.tsx | 4 +- .../__snapshots__/index.test.tsx.snap | 146 +- components/locale/__tests__/config.test.tsx | 6 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 4 +- components/mentions/__tests__/index.test.tsx | 16 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 12 +- components/menu/__tests__/index.test.tsx | 157 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- components/message/__tests__/config.test.tsx | 10 +- components/message/__tests__/hooks.test.tsx | 10 +- .../message/__tests__/immediately.test.tsx | 8 +- components/message/__tests__/index.test.tsx | 28 +- .../message/__tests__/static-warning.test.tsx | 8 +- components/message/__tests__/type.test.tsx | 10 +- components/message/__tests__/util.ts | 2 +- components/modal/__tests__/Modal.test.tsx | 8 +- .../__snapshots__/Modal.test.tsx.snap | 10 +- .../__snapshots__/confirm.test.tsx.snap | 4 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- components/modal/__tests__/confirm.test.tsx | 138 +- components/modal/__tests__/hook.test.tsx | 22 +- .../modal/__tests__/static-warning.test.tsx | 10 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../notification/__tests__/config.test.tsx | 12 +- .../notification/__tests__/hooks.test.tsx | 8 +- .../notification/__tests__/index.test.tsx | 12 +- .../notification/__tests__/placement.test.tsx | 6 +- .../__tests__/static-warning.test.tsx | 8 +- components/notification/__tests__/util.ts | 2 +- .../__snapshots__/demo-extend.test.ts.snap | 352 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 8 +- .../pagination/__tests__/index.test.tsx | 6 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 8 +- .../popconfirm/__tests__/index.test.tsx | 32 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 6 +- components/popover/__tests__/index.test.tsx | 4 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 42 +- components/progress/__tests__/index.test.tsx | 20 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 8 +- components/qrcode/__tests__/index.test.tsx | 6 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/group.test.tsx.snap | 4 +- .../__snapshots__/radio-button.test.tsx.snap | 8 +- .../__snapshots__/radio.test.tsx.snap | 10 +- components/radio/__tests__/group.test.tsx | 26 +- .../radio/__tests__/radio-button.test.tsx | 24 +- components/radio/__tests__/radio.test.tsx | 8 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.ts.snap | 4 +- .../__snapshots__/demo-extend.test.ts.snap | 54 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 4 +- components/result/__tests__/index.test.tsx | 2 +- .../__snapshots__/demo-extend.test.ts.snap | 4 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 32 +- components/segmented/__tests__/index.test.tsx | 22 +- .../__snapshots__/demo-extend.test.ts.snap | 66 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 8 +- components/select/__tests__/index.test.tsx | 16 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 206 +- .../__snapshots__/demo-extend.test.ts.snap | 180 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 10 +- components/slider/__tests__/index.test.tsx | 35 +- .../__snapshots__/demo-extend.test.ts.snap | 30 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 12 +- .../__snapshots__/space-compact.test.tsx.snap | 6 +- components/space/__tests__/gap.test.tsx | 2 +- components/space/__tests__/index.test.tsx | 2 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 10 +- components/spin/__tests__/delay.test.tsx | 28 +- components/spin/__tests__/index.test.tsx | 8 +- .../__snapshots__/demo-extend.test.ts.snap | 60 +- .../__tests__/__snapshots__/demo.test.ts.snap | 56 +- .../__snapshots__/index.test.tsx.snap | 6 +- components/statistic/__tests__/index.test.tsx | 34 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 10 +- components/steps/__tests__/index.test.tsx | 2 +- .../__snapshots__/demo-extend.test.ts.snap | 94 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 4 +- components/switch/__tests__/index.test.tsx | 16 +- components/switch/__tests__/wave.test.tsx | 8 +- .../table/__tests__/Table.filter.test.tsx | 136 +- .../table/__tests__/Table.order.test.tsx | 2 +- .../table/__tests__/Table.pagination.test.tsx | 44 +- .../__tests__/Table.rowSelection.test.tsx | 134 +- .../table/__tests__/Table.sorter.test.tsx | 32 +- components/table/__tests__/Table.test.tsx | 23 +- .../__snapshots__/Table.expand.test.tsx.snap | 4 +- .../__snapshots__/Table.filter.test.tsx.snap | 22 +- .../Table.pagination.test.tsx.snap | 10 +- .../Table.rowSelection.test.tsx.snap | 16 +- .../__snapshots__/Table.sorter.test.tsx.snap | 6 +- .../__snapshots__/Table.test.tsx.snap | 12 +- .../__snapshots__/demo-extend.test.ts.snap | 18 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/empty.test.tsx.snap | 10 +- .../__snapshots__/demo-extend.test.ts.snap | 10 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 12 +- components/tabs/__tests__/index.test.tsx | 9 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- components/tag/__tests__/index.test.tsx | 36 +- .../__snapshots__/demo-extend.test.ts.snap | 40 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 10 +- .../time-picker/__tests__/index.test.tsx | 4 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 6 +- components/timeline/__tests__/index.test.tsx | 2 +- .../__snapshots__/demo-extend.test.ts.snap | 120 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/tooltip.test.tsx.snap | 12 +- components/tooltip/__tests__/tooltip.test.tsx | 38 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 22 +- components/tour/__tests__/index.test.tsx | 4 +- .../__snapshots__/demo-extend.test.ts.snap | 9713 ----------------- .../__tests__/__snapshots__/demo.test.ts.snap | 4 +- .../__snapshots__/index.test.tsx.snap | 12 +- .../__snapshots__/list.test.tsx.snap | 4 +- .../__snapshots__/search.test.tsx.snap | 6 +- .../transfer/__tests__/customize.test.tsx | 4 +- .../transfer/__tests__/dropdown.test.tsx | 32 +- components/transfer/__tests__/index.test.tsx | 32 +- components/transfer/__tests__/search.test.tsx | 12 +- .../__snapshots__/demo-extend.test.ts.snap | 484 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 12 +- .../tree-select/__tests__/index.test.tsx | 4 +- .../__snapshots__/demo-extend.test.ts.snap | 460 +- .../__tests__/__snapshots__/demo.test.ts.snap | 24 +- .../__snapshots__/directory.test.tsx.snap | 46 +- .../__snapshots__/index.test.tsx.snap | 18 +- components/tree/__tests__/directory.test.tsx | 46 +- components/tree/__tests__/index.test.tsx | 6 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__snapshots__/demo.test.tsx.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 10 +- components/typography/__tests__/copy.test.tsx | 40 +- .../typography/__tests__/editable.test.tsx | 6 +- .../typography/__tests__/ellipsis.test.tsx | 65 +- .../__tests__/enter-key-callback.test.tsx | 10 +- .../typography/__tests__/index.test.tsx | 47 +- .../__snapshots__/demo-extend.test.ts.snap | 2 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/upload.test.tsx.snap | 4 +- .../__snapshots__/uploadlist.test.tsx.snap | 16 +- components/upload/__tests__/dragger.test.tsx | 18 +- components/upload/__tests__/upload.test.tsx | 135 +- .../upload/__tests__/uploadlist.test.tsx | 187 +- .../__snapshots__/demo-extend.test.ts.snap | 13 +- .../__tests__/__snapshots__/demo.test.ts.snap | 2 +- .../__snapshots__/index.test.tsx.snap | 26 +- components/watermark/__tests__/index.test.tsx | 6 +- package.json | 7 +- tests/__mocks__/rc-virtual-list.ts | 3 - tests/__snapshots__/index.test.ts.snap | 2 +- tests/index.test.ts | 14 +- tests/setup.ts | 191 + tests/shared/accessibilityTest.tsx | 6 +- tests/shared/demoTest.tsx | 16 +- tests/shared/excludeWarning.tsx | 2 +- tests/shared/focusTest.tsx | 20 +- tests/shared/imageTest.tsx | 4 +- tests/shared/rootPropsTest.tsx | 8 +- tests/utils.tsx | 17 +- tsconfig.json | 5 +- typings/jest.d.ts | 5 - typings/vitest.ts | 2 + vitest.config.ts | 56 + 397 files changed, 4184 insertions(+), 17971 deletions(-) rename {tests/__mocks__ => __mocks__}/@rc-component/trigger.tsx (65%) rename {tests/__mocks__ => __mocks__}/copy-to-clipboard.ts (100%) rename {tests/__mocks__ => __mocks__}/rc-trigger.tsx (68%) rename {tests/__mocks__/rc-util/lib => __mocks__/rc-util/es}/Portal.tsx (78%) create mode 100644 __mocks__/rc-virtual-list.ts delete mode 100644 components/drawer/__tests__/__snapshots__/demo-extend.test.tsx.snap delete mode 100644 components/transfer/__tests__/__snapshots__/demo-extend.test.ts.snap delete mode 100644 tests/__mocks__/rc-virtual-list.ts create mode 100644 tests/setup.ts delete mode 100644 typings/jest.d.ts create mode 100644 typings/vitest.ts create mode 100644 vitest.config.ts diff --git a/tests/__mocks__/@rc-component/trigger.tsx b/__mocks__/@rc-component/trigger.tsx similarity index 65% rename from tests/__mocks__/@rc-component/trigger.tsx rename to __mocks__/@rc-component/trigger.tsx index b9c9d5c88d47..c199b787d466 100644 --- a/tests/__mocks__/@rc-component/trigger.tsx +++ b/__mocks__/@rc-component/trigger.tsx @@ -1,16 +1,17 @@ import type { TriggerProps } from '@rc-component/trigger'; -import MockTrigger from '@rc-component/trigger/lib/mock'; +import MockTrigger from '@rc-component/trigger/es/mock'; import * as React from 'react'; -import { TriggerMockContext } from '../../shared/demoTestContext'; +import { TriggerMockContext } from '../../tests/shared/demoTestContext'; -let OriginTrigger = jest.requireActual('@rc-component/trigger'); -OriginTrigger = OriginTrigger.default ?? OriginTrigger; +const { default: OriginTrigger } = await vi.importActual( + '@rc-component/trigger', +); const ForwardTrigger = React.forwardRef((props, ref) => { const context = React.useContext(TriggerMockContext); const mergedPopupVisible = context?.popupVisible ?? props.popupVisible; - (global as any).triggerProps = props; + globalThis.triggerProps = props; const mergedProps = { ...props, diff --git a/tests/__mocks__/copy-to-clipboard.ts b/__mocks__/copy-to-clipboard.ts similarity index 100% rename from tests/__mocks__/copy-to-clipboard.ts rename to __mocks__/copy-to-clipboard.ts diff --git a/tests/__mocks__/rc-trigger.tsx b/__mocks__/rc-trigger.tsx similarity index 68% rename from tests/__mocks__/rc-trigger.tsx rename to __mocks__/rc-trigger.tsx index 44631901fe5e..a65a367b655f 100644 --- a/tests/__mocks__/rc-trigger.tsx +++ b/__mocks__/rc-trigger.tsx @@ -1,16 +1,15 @@ import type { TriggerProps } from 'rc-trigger'; -import MockTrigger from 'rc-trigger/lib/mock'; +import MockTrigger from 'rc-trigger/es/mock'; import * as React from 'react'; -import { TriggerMockContext } from '../shared/demoTestContext'; +import { TriggerMockContext } from '../tests/shared/demoTestContext'; -let OriginTrigger = jest.requireActual('rc-trigger'); -OriginTrigger = OriginTrigger.default ?? OriginTrigger; +const { default: OriginTrigger } = await vi.importActual('rc-trigger'); const ForwardTrigger = React.forwardRef((props, ref) => { const context = React.useContext(TriggerMockContext); const mergedPopupVisible = context?.popupVisible ?? props.popupVisible; - (global as any).triggerProps = props; + globalThis.triggerProps = props as any; const mergedProps = { ...props, diff --git a/tests/__mocks__/rc-util/lib/Portal.tsx b/__mocks__/rc-util/es/Portal.tsx similarity index 78% rename from tests/__mocks__/rc-util/lib/Portal.tsx rename to __mocks__/rc-util/es/Portal.tsx index 9fe393670f86..2858c6319f29 100644 --- a/tests/__mocks__/rc-util/lib/Portal.tsx +++ b/__mocks__/rc-util/es/Portal.tsx @@ -1,8 +1,8 @@ import React from 'react'; -import { TriggerMockContext } from '../../../shared/demoTestContext'; +import { TriggerMockContext } from '../../../tests/shared/demoTestContext'; + +const { default: OriginPortal } = await vi.importActual('rc-util/es/Portal'); -let OriginPortal = jest.requireActual('rc-util/lib/Portal'); -OriginPortal = OriginPortal.default ?? OriginPortal; class MockPortal extends React.Component<{ children?: React.ReactNode }> { container: boolean; diff --git a/__mocks__/rc-virtual-list.ts b/__mocks__/rc-virtual-list.ts new file mode 100644 index 000000000000..22cd22f5be60 --- /dev/null +++ b/__mocks__/rc-virtual-list.ts @@ -0,0 +1 @@ +export { default as default } from 'rc-virtual-list/es/mock'; diff --git a/components/__tests__/__snapshots__/index.test.ts.snap b/components/__tests__/__snapshots__/index.test.ts.snap index 8572ab796ffb..a6f6d0399c22 100644 --- a/components/__tests__/__snapshots__/index.test.ts.snap +++ b/components/__tests__/__snapshots__/index.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`antd exports modules correctly 1`] = ` +exports[`antd > exports modules correctly 1`] = ` [ "Affix", "Alert", @@ -37,7 +37,9 @@ exports[`antd exports modules correctly 1`] = ` "List", "Mentions", "Menu", + "message", "Modal", + "notification", "Pagination", "Popconfirm", "Popover", @@ -59,6 +61,7 @@ exports[`antd exports modules correctly 1`] = ` "Table", "Tabs", "Tag", + "theme", "TimePicker", "Timeline", "Tooltip", @@ -68,10 +71,7 @@ exports[`antd exports modules correctly 1`] = ` "TreeSelect", "Typography", "Upload", - "Watermark", - "message", - "notification", - "theme", "version", + "Watermark", ] `; diff --git a/components/__tests__/__snapshots__/setup.test.tsx.snap b/components/__tests__/__snapshots__/setup.test.tsx.snap index f2e4db6141ac..c3c40d4094ec 100644 --- a/components/__tests__/__snapshots__/setup.test.tsx.snap +++ b/components/__tests__/__snapshots__/setup.test.tsx.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`SetUp.Test diff of React 18 & React 17 1`] = ` +exports[`SetUp.Test > diff of React 18 & React 17 1`] = ` NodeList [
bamboo diff --git a/components/__tests__/index.test.ts b/components/__tests__/index.test.ts index 9ab8d246ba51..a103f2129876 100644 --- a/components/__tests__/index.test.ts +++ b/components/__tests__/index.test.ts @@ -1,13 +1,13 @@ const OLD_NODE_ENV = process.env.NODE_ENV; process.env.NODE_ENV = 'development'; -const antd = require('..'); describe('antd', () => { afterAll(() => { process.env.NODE_ENV = OLD_NODE_ENV; }); - it('exports modules correctly', () => { + it('exports modules correctly', async () => { + const antd = await import('../index'); expect(Object.keys(antd)).toMatchSnapshot(); }); }); diff --git a/components/__tests__/node.test.tsx b/components/__tests__/node.test.tsx index cc63dd37e41d..76df67ea10b2 100644 --- a/components/__tests__/node.test.tsx +++ b/components/__tests__/node.test.tsx @@ -5,19 +5,22 @@ import type { Options } from '../../tests/shared/demoTest'; (global as any).testConfig = {}; -jest.mock('../../tests/shared/demoTest', () => { +vi.mock('../../tests/shared/demoTest', () => { function fakeDemoTest(name: string, option: Options = {}) { (global as any).testConfig[name] = option; } fakeDemoTest.rootPropsTest = () => {}; - return fakeDemoTest; + return { + default: fakeDemoTest, + rootPropsTest: () => {}, + }; }); describe('node', () => { beforeAll(() => { - jest.useFakeTimers().setSystemTime(new Date('2016-11-22')); + vi.useFakeTimers().setSystemTime(new Date('2016-11-22')); }); // Find the component exist demo test file @@ -27,19 +30,20 @@ describe('node', () => { const componentName = componentTestFile.match(/components\/([^/]*)\//)![1]; // Test for ssr - describe(componentName, () => { + // eslint-disable-next-line jest/valid-describe-callback + describe(componentName, async () => { const demoList = globSync(`./components/${componentName}/demo/*.tsx`); // Use mock to get config - require(`../../${componentTestFile}`); // eslint-disable-line global-require, import/no-dynamic-require + await import(`../../${componentTestFile}`); const option = (global as any).testConfig?.[componentName]; demoList.forEach((demoFile) => { const skip: string[] = option?.skip || []; const test = skip.some((skipMarkdown) => demoFile.includes(skipMarkdown)) ? it.skip : it; - test(demoFile, () => { - const Demo = require(`../../${demoFile}`).default; // eslint-disable-line global-require, import/no-dynamic-require + test(demoFile, async () => { + const Demo = (await import(`../../${demoFile}`)).default; expect(() => { renderToString(); }).not.toThrow(); diff --git a/components/_util/__tests__/getScroll.test.ts b/components/_util/__tests__/getScroll.test.ts index 8cb737ff1a40..0eb77443ad93 100644 --- a/components/_util/__tests__/getScroll.test.ts +++ b/components/_util/__tests__/getScroll.test.ts @@ -7,7 +7,7 @@ describe('getScroll', () => { }); it('getScroll window', async () => { - const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation((x, y) => { + const scrollToSpy = vi.spyOn(window, 'scrollTo').mockImplementation((x, y) => { window.pageXOffset = x; window.pageYOffset = y; }); @@ -18,7 +18,7 @@ describe('getScroll', () => { }); it('getScroll document', async () => { - const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation((x, y) => { + const scrollToSpy = vi.spyOn(window, 'scrollTo').mockImplementation((x, y) => { document.documentElement.scrollLeft = x; document.documentElement.scrollTop = y; }); @@ -30,7 +30,7 @@ describe('getScroll', () => { it('getScroll div', async () => { const div = document.createElement('div'); - const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation((x, y) => { + const scrollToSpy = vi.spyOn(window, 'scrollTo').mockImplementation((x, y) => { div.scrollLeft = x; div.scrollTop = y; }); @@ -42,7 +42,7 @@ describe('getScroll', () => { it('getScroll documentElement', async () => { const div: any = {}; - const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation((x, y) => { + const scrollToSpy = vi.spyOn(window, 'scrollTo').mockImplementation((x, y) => { div.scrollLeft = null; div.scrollTop = null; div.documentElement = {}; diff --git a/components/_util/__tests__/responsiveObserve.test.tsx b/components/_util/__tests__/responsiveObserve.test.tsx index d88c5ea6066c..b47595d4cdc0 100644 --- a/components/_util/__tests__/responsiveObserve.test.tsx +++ b/components/_util/__tests__/responsiveObserve.test.tsx @@ -11,7 +11,7 @@ describe('Test ResponsiveObserve', () => { return null; }; render(); - const subscribeFunc = jest.fn(); + const subscribeFunc = vi.fn(); const token = responsiveObserveRef.subscribe(subscribeFunc); expect( responsiveObserveRef.matchHandlers[responsiveObserveRef.responsiveMap.xs].mql.matches, diff --git a/components/_util/__tests__/scrollTo.test.ts b/components/_util/__tests__/scrollTo.test.ts index 5fe2e09502c0..a6e7533c1cac 100644 --- a/components/_util/__tests__/scrollTo.test.ts +++ b/components/_util/__tests__/scrollTo.test.ts @@ -2,10 +2,10 @@ import { waitFakeTimer } from '../../../tests/utils'; import scrollTo from '../scrollTo'; describe('Test ScrollTo function', () => { - const dateNowMock = jest.spyOn(Date, 'now'); + const dateNowMock = vi.spyOn(Date, 'now'); beforeAll(() => { - jest.useFakeTimers(); + vi.useFakeTimers(); }); beforeEach(() => { @@ -13,16 +13,16 @@ describe('Test ScrollTo function', () => { }); afterAll(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); afterEach(() => { - jest.clearAllTimers(); + vi.clearAllTimers(); dateNowMock.mockClear(); }); it('test scrollTo', async () => { - const scrollToSpy = jest.spyOn(window, 'scrollTo').mockImplementation((_, y) => { + const scrollToSpy = vi.spyOn(window, 'scrollTo').mockImplementation((_, y) => { window.scrollY = y; window.pageYOffset = y; }); @@ -36,7 +36,7 @@ describe('Test ScrollTo function', () => { }); it('test callback - option', async () => { - const cbMock = jest.fn(); + const cbMock = vi.fn(); scrollTo(1000, { callback: cbMock, }); diff --git a/components/_util/__tests__/util.test.tsx b/components/_util/__tests__/util.test.tsx index 70b8950c4c70..8dd5090131b6 100644 --- a/components/_util/__tests__/util.test.tsx +++ b/components/_util/__tests__/util.test.tsx @@ -1,7 +1,7 @@ /* eslint-disable class-methods-use-this */ import KeyCode from 'rc-util/lib/KeyCode'; import React from 'react'; -import { waitFakeTimer, render, fireEvent } from '../../../tests/utils'; +import { fireEvent, render, waitFakeTimer } from '../../../tests/utils'; import getDataOrAriaProps from '../getDataOrAriaProps'; import { isStyleSupport } from '../styleChecker'; import throttleByAnimationFrame from '../throttleByAnimationFrame'; @@ -10,19 +10,19 @@ import TransButton from '../transButton'; describe('Test utils function', () => { describe('throttle', () => { beforeAll(() => { - jest.useFakeTimers(); + vi.useFakeTimers(); }); afterAll(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); afterEach(() => { - jest.clearAllTimers(); + vi.clearAllTimers(); }); it('throttle function should work', async () => { - const callback = jest.fn(); + const callback = vi.fn(); const throttled = throttleByAnimationFrame(callback); expect(callback).not.toHaveBeenCalled(); @@ -35,7 +35,7 @@ describe('Test utils function', () => { }); it('throttle function should be canceled', async () => { - const callback = jest.fn(); + const callback = vi.fn(); const throttled = throttleByAnimationFrame(callback); throttled(); @@ -106,7 +106,7 @@ describe('Test utils function', () => { }); it('should trigger onClick when press enter', () => { - const onClick = jest.fn(); + const onClick = vi.fn(); const { container } = render(TransButton); diff --git a/components/_util/__tests__/warning.test.ts b/components/_util/__tests__/warning.test.ts index 00a952bd49d8..f57b961f079e 100644 --- a/components/_util/__tests__/warning.test.ts +++ b/components/_util/__tests__/warning.test.ts @@ -1,8 +1,10 @@ +import { SpyInstance } from 'vitest'; + describe('Test warning', () => { - let spy: jest.SpyInstance; + let spy: SpyInstance; beforeAll(() => { - spy = jest.spyOn(console, 'error').mockImplementation(() => {}); + spy = vi.spyOn(console, 'error').mockImplementation(() => {}); }); afterAll(() => { @@ -10,7 +12,7 @@ describe('Test warning', () => { }); beforeEach(() => { - jest.resetModules(); + vi.resetModules(); }); afterEach(() => { diff --git a/components/_util/__tests__/wave.test.tsx b/components/_util/__tests__/wave.test.tsx index b6829855b1ea..ca20ae1adfd5 100644 --- a/components/_util/__tests__/wave.test.tsx +++ b/components/_util/__tests__/wave.test.tsx @@ -1,11 +1,11 @@ import React from 'react'; import mountTest from '../../../tests/shared/mountTest'; -import { render, fireEvent, getByText, waitFakeTimer, act } from '../../../tests/utils'; +import { act, fireEvent, getByText, render, waitFakeTimer } from '../../../tests/utils'; import Wave from '../wave'; (global as any).isVisible = true; -jest.mock('rc-util/lib/Dom/isVisible', () => { +vi.mock('rc-util/lib/Dom/isVisible', () => { const mockFn = () => (global as any).isVisible; return mockFn; }); @@ -29,11 +29,11 @@ describe('Wave component', () => { } (window as any).ResizeObserver = FakeResizeObserver; - jest.useFakeTimers(); + vi.useFakeTimers(); }); afterAll(() => { - jest.useRealTimers(); + vi.useRealTimers(); expect(obCnt).not.toBe(0); expect(disCnt).not.toBe(0); }); @@ -44,7 +44,7 @@ describe('Wave component', () => { }); afterEach(() => { - jest.clearAllTimers(); + vi.clearAllTimers(); const styles = document.getElementsByTagName('style'); for (let i = 0; i < styles.length; i += 1) { styles[i].remove(); @@ -66,7 +66,7 @@ describe('Wave component', () => { function waitRaf() { act(() => { - jest.advanceTimersByTime(100); + vi.advanceTimersByTime(100); }); } diff --git a/components/affix/__tests__/Affix.test.tsx b/components/affix/__tests__/Affix.test.tsx index cbe9b44815e0..bebd688af11d 100644 --- a/components/affix/__tests__/Affix.test.tsx +++ b/components/affix/__tests__/Affix.test.tsx @@ -42,12 +42,12 @@ describe('Affix Render', () => { rtlTest(Affix); accessibilityTest(Affix); - const domMock = jest.spyOn(HTMLElement.prototype, 'getBoundingClientRect'); + const domMock = vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect'); const classRect: Record = { container: { top: 0, bottom: 100 } as DOMRect }; beforeEach(() => { - jest.useFakeTimers(); + vi.useFakeTimers(); }); beforeAll(() => { @@ -57,8 +57,8 @@ describe('Affix Render', () => { }); afterEach(() => { - jest.useRealTimers(); - jest.clearAllTimers(); + vi.useRealTimers(); + vi.clearAllTimers(); }); afterAll(() => { @@ -109,7 +109,7 @@ describe('Affix Render', () => { }); it('updatePosition when offsetTop changed', async () => { - const onChange = jest.fn(); + const onChange = vi.fn(); const { container, rerender } = render(); await waitFakeTimer(); @@ -228,7 +228,7 @@ describe('Affix Render', () => { '.fixed', // outer ].forEach((selector) => { it(`trigger listener when size change: ${selector}`, async () => { - const updateCalled = jest.fn(); + const updateCalled = vi.fn(); const { container } = render( , { diff --git a/components/affix/__tests__/__snapshots__/Affix.test.tsx.snap b/components/affix/__tests__/__snapshots__/Affix.test.tsx.snap index bd230c7ac40d..1d68a8068ffa 100644 --- a/components/affix/__tests__/__snapshots__/Affix.test.tsx.snap +++ b/components/affix/__tests__/__snapshots__/Affix.test.tsx.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Affix Render rtl render component should be rendered correctly in RTL direction 1`] = ` +exports[`Affix Render > rtl render > component should be rendered correctly in RTL direction 1`] = `
custom action 1`] = `
`; -exports[`Alert rtl render component should be rendered correctly in RTL direction 1`] = ` +exports[`Alert > rtl render > component should be rendered correctly in RTL direction 1`] = `
{ accessibilityTest(Alert); beforeAll(() => { - jest.useFakeTimers(); + vi.useFakeTimers(); }); afterAll(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('should show close button and could be closed', async () => { - const onClose = jest.fn(); + const onClose = vi.fn(); render( { await userEvent.click(screen.getByRole('button', { name: /close/i })); - act(() => { - jest.runAllTimers(); - }); - expect(onClose).toHaveBeenCalledTimes(1); }); @@ -76,7 +72,7 @@ describe('Alert', () => { }); it('should show error as ErrorBoundary when children have error', () => { - const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + const warnSpy = vi.spyOn(console, 'error').mockImplementation(() => {}); expect(warnSpy).toHaveBeenCalledTimes(0); // @ts-expect-error // eslint-disable-next-line react/jsx-no-undef @@ -105,10 +101,6 @@ describe('Alert', () => { await userEvent.hover(screen.getByRole('alert')); - act(() => { - jest.runAllTimers(); - }); - expect(screen.getByRole('tooltip')).toBeInTheDocument(); }); @@ -123,10 +115,6 @@ describe('Alert', () => { ); await userEvent.click(screen.getByRole('alert')); - act(() => { - jest.runAllTimers(); - }); - expect(screen.getByRole('tooltip')).toBeInTheDocument(); }); diff --git a/components/anchor/__tests__/Anchor.test.tsx b/components/anchor/__tests__/Anchor.test.tsx index 51cf8972649d..b9850ed36f8e 100644 --- a/components/anchor/__tests__/Anchor.test.tsx +++ b/components/anchor/__tests__/Anchor.test.tsx @@ -2,6 +2,7 @@ import { resetWarned } from 'rc-util/lib/warning'; import React, { useState } from 'react'; import scrollIntoView from 'scroll-into-view-if-needed'; +import type { SpyInstance } from 'vitest'; import Anchor from '..'; import { act, fireEvent, render, waitFakeTimer } from '../../../tests/utils'; import Button from '../../button'; @@ -18,18 +19,16 @@ function createDiv() { let idCounter = 0; const getHashUrl = () => `Anchor-API-${idCounter++}`; -jest.mock('scroll-into-view-if-needed', () => jest.fn()); +vi.mock('scroll-into-view-if-needed', () => ({ + default: vi.fn(), +})); describe('Anchor Render', () => { - const getBoundingClientRectMock = jest.spyOn( - HTMLHeadingElement.prototype, - 'getBoundingClientRect', - ); - const getClientRectsMock = jest.spyOn(HTMLHeadingElement.prototype, 'getClientRects'); - const scrollIntoViewMock = jest.createMockFromModule('scroll-into-view-if-needed'); + const getBoundingClientRectMock = vi.spyOn(HTMLHeadingElement.prototype, 'getBoundingClientRect'); + const getClientRectsMock = vi.spyOn(HTMLHeadingElement.prototype, 'getClientRects'); beforeAll(() => { - jest.useFakeTimers(); + vi.useFakeTimers(); getBoundingClientRectMock.mockReturnValue({ width: 100, height: 100, @@ -39,18 +38,18 @@ describe('Anchor Render', () => { }); beforeEach(() => { - jest.useFakeTimers(); - scrollIntoViewMock.mockReset(); + vi.useFakeTimers(); + vi.mocked(scrollIntoView).mockReset(); }); afterEach(() => { - jest.clearAllTimers(); - jest.useRealTimers(); + vi.clearAllTimers(); + vi.useRealTimers(); }); afterAll(() => { - jest.clearAllTimers(); - jest.useRealTimers(); + vi.clearAllTimers(); + vi.useRealTimers(); getBoundingClientRectMock.mockRestore(); getClientRectsMock.mockRestore(); }); @@ -186,12 +185,12 @@ describe('Anchor Render', () => { const link = container.querySelector(`a[href="http://www.example.com/#${hash}"]`)!; fireEvent.click(link); await waitFakeTimer(); - expect(link.classList).toContain('ant-anchor-link-title-active'); + expect(link.classList.contains('ant-anchor-link-title-active')).toBeTruthy(); }); it('scrolls the page when clicking a link', async () => { const root = createDiv(); - const scrollToSpy = jest.spyOn(window, 'scrollTo'); + const scrollToSpy = vi.spyOn(window, 'scrollTo'); render(
Q1
, { container: root }); const { container } = render( , @@ -206,7 +205,7 @@ describe('Anchor Render', () => { const hash1 = getHashUrl(); const hash2 = getHashUrl(); const root = createDiv(); - const onChange = jest.fn(); + const onChange = vi.fn(); render(
Hello
@@ -265,7 +264,7 @@ describe('Anchor Render', () => { it('targetOffset prop', async () => { const hash = getHashUrl(); - const scrollToSpy = jest.spyOn(window, 'scrollTo'); + const scrollToSpy = vi.spyOn(window, 'scrollTo'); const root = createDiv(); render(

Hello

, { container: root }); const { container, rerender } = render( @@ -296,7 +295,7 @@ describe('Anchor Render', () => { it('targetOffset prop when contain spaces', async () => { const hash = `${getHashUrl()} s p a c e s`; - const scrollToSpy = jest.spyOn(window, 'scrollTo'); + const scrollToSpy = vi.spyOn(window, 'scrollTo'); const root = createDiv(); render(

Hello

, { container: root }); const { container, rerender } = render( @@ -347,7 +346,7 @@ describe('Anchor Render', () => { it('onChange event', () => { const hash1 = getHashUrl(); const hash2 = getHashUrl(); - const onChange = jest.fn(); + const onChange = vi.fn(); const { container } = render( { const hash1 = getHashUrl(); const hash2 = getHashUrl(); - const beforeFn = jest.fn(); - const afterFn = jest.fn(); + const beforeFn = vi.fn(); + const afterFn = vi.fn(); const Demo: React.FC = () => { const [trigger, setTrigger] = useState(false); @@ -435,7 +434,7 @@ describe('Anchor Render', () => { getBoundingClientRectMock.mockReturnValue({ width: 0, height: 0, top: 1000 } as DOMRect); const hash = getHashUrl(); - const scrollToSpy = jest.spyOn(window, 'scrollTo'); + const scrollToSpy = vi.spyOn(window, 'scrollTo'); const root = createDiv(); render(

Hello

, { container: root }); const { container, rerender } = render( @@ -472,10 +471,10 @@ describe('Anchor Render', () => { } as DOMRect); }); - it('test edge case when container is not windows', async () => { + it.todo('test edge case when container is not windows', async () => { const hash = getHashUrl(); - const scrollToSpy = jest.spyOn(window, 'scrollTo'); + const scrollToSpy = vi.spyOn(window, 'scrollTo'); const root = createDiv(); render(

Hello

, { container: root }); @@ -529,7 +528,7 @@ describe('Anchor Render', () => { it('should trigger onChange when have getCurrentAnchor', () => { const hash1 = getHashUrl(); const hash2 = getHashUrl(); - const onChange = jest.fn(); + const onChange = vi.fn(); const { container } = render( { it('getCurrentAnchor have default link as argument', () => { const hash1 = getHashUrl(); const hash2 = getHashUrl(); - const getCurrentAnchor = jest.fn(); + const getCurrentAnchor = vi.fn(); const { container } = render( { describe('scroll x', () => { it('targetOffset horizontal', async () => { const hash = getHashUrl(); - const scrollToSpy = jest.spyOn(window, 'scrollTo'); + const scrollToSpy = vi.spyOn(window, 'scrollTo'); const root = createDiv(); render(

Hello

, { container: root }); const { container, rerender } = render( @@ -756,12 +755,12 @@ describe('Anchor Render', () => { const link = container.querySelector(`a[href="http://www.example.com/#${hash}"]`)!; fireEvent.click(link); await waitFakeTimer(); - expect(link.classList).toContain('ant-anchor-link-title-active'); + expect(link.classList.contains('ant-anchor-link-title-active')).toBeTruthy(); }); it('scrolls the page when clicking a link', async () => { const root = createDiv(); - const scrollToSpy = jest.spyOn(window, 'scrollTo'); + const scrollToSpy = vi.spyOn(window, 'scrollTo'); render(
Q1
, { container: root }); const { container } = render( @@ -778,7 +777,7 @@ describe('Anchor Render', () => { const hash1 = getHashUrl(); const hash2 = getHashUrl(); const root = createDiv(); - const onChange = jest.fn(); + const onChange = vi.fn(); render(
Hello
@@ -851,10 +850,10 @@ describe('Anchor Render', () => { }); describe('warning', () => { - let errSpy: jest.SpyInstance; + let errSpy: SpyInstance; beforeEach(() => { resetWarned(); - errSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + errSpy = vi.spyOn(console, 'error').mockImplementation(() => {}); }); afterEach(() => { @@ -971,14 +970,14 @@ describe('Anchor Render', () => { const toggleButton = wrapper.container.querySelector('button')!; fireEvent.click(toggleButton); - act(() => jest.runAllTimers()); + act(() => vi.runAllTimers()); expect(!!ink.style.left).toBe(true); expect(!!ink.style.width).toBe(true); expect(ink.style.top).toBe(''); expect(ink.style.height).toBe(''); fireEvent.click(toggleButton); - act(() => jest.runAllTimers()); + act(() => vi.runAllTimers()); expect(!!ink.style.top).toBe(true); expect(!!ink.style.height).toBe(true); expect(ink.style.left).toBe(''); diff --git a/components/anchor/__tests__/__snapshots__/Anchor.test.tsx.snap b/components/anchor/__tests__/__snapshots__/Anchor.test.tsx.snap index aa6da33ae783..0a030f440b25 100644 --- a/components/anchor/__tests__/__snapshots__/Anchor.test.tsx.snap +++ b/components/anchor/__tests__/__snapshots__/Anchor.test.tsx.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Anchor Render render items and ignore jsx children 1`] = ` +exports[`Anchor Render > render items and ignore jsx children 1`] = `
`; -exports[`Anchor Render renders items correctly 1`] = ` +exports[`Anchor Render > renders items correctly 1`] = `
`; -exports[`Anchor Render renders items correctly#horizontal 1`] = ` +exports[`Anchor Render > renders items correctly#horizontal 1`] = `
rtl render > component should be rendered correctly in RTL direction 1`] = `
`; -exports[`App single 1`] = ` +exports[`App > single 1`] = `
diff --git a/components/app/__tests__/index.test.tsx b/components/app/__tests__/index.test.tsx index c738a60a203d..4d528e7e9ebc 100644 --- a/components/app/__tests__/index.test.tsx +++ b/components/app/__tests__/index.test.tsx @@ -11,12 +11,12 @@ describe('App', () => { rtlTest(App); beforeEach(() => { - jest.useFakeTimers(); + vi.useFakeTimers(); }); afterEach(() => { - jest.clearAllTimers(); - jest.useRealTimers(); + vi.clearAllTimers(); + vi.useRealTimers(); }); it('single', () => { diff --git a/components/auto-complete/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/auto-complete/__tests__/__snapshots__/demo-extend.test.ts.snap index 74e10a5422ec..126a275dc4c9 100644 --- a/components/auto-complete/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/auto-complete/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`renders components/auto-complete/demo/basic.tsx extend context correctly 1`] = ` Array [ @@ -188,7 +188,7 @@ exports[`renders components/auto-complete/demo/certain-category.tsx extend conte >
rtl render > component should be rendered correctly in RTL direction 1`] = `