diff --git a/.fatherrc.js b/.fatherrc.js
index 912aa0aae..205e08f0d 100644
--- a/.fatherrc.js
+++ b/.fatherrc.js
@@ -1,9 +1,10 @@
-export default {
- cjs: 'babel',
- esm: { type: 'babel', importLibToEs: true },
- preCommit: {
- eslint: true,
- prettier: true,
+import { defineConfig } from 'father';
+
+export default defineConfig({
+ platform: 'browser',
+ cjs: { output: 'lib' },
+ esm: {
+ output: 'es',
+ alias: { 'rc-util/lib': 'rc-util/es' },
},
- runtimeHelpers: true,
-};
+});
\ No newline at end of file
diff --git a/package.json b/package.json
index 4adbe7b87..d37332d64 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
"compile": "father build",
"prepublishOnly": "npm run compile && np --yolo --no-publish",
"lint": "eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js",
- "test": "father test",
+ "test": "rc-test",
"tsc": "tsc --noEmit",
"now-build": "npm run build"
},
@@ -63,11 +63,12 @@
"enzyme": "^3.3.0",
"enzyme-to-json": "^3.4.0",
"eslint": "^7.1.0",
- "father": "^2.13.2",
+ "father": "^4.0.0",
"jsonp": "^0.2.1",
"np": "^7.5.0",
"prettier": "^2.7.1",
"rc-dialog": "^9.0.0",
+ "rc-test": "^7.0.9",
"typescript": "^4.2.3"
}
-}
+}
\ No newline at end of file
diff --git a/tests/Hooks.test.tsx b/tests/Hooks.test.tsx
index 31986f12b..1868f29cd 100644
--- a/tests/Hooks.test.tsx
+++ b/tests/Hooks.test.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { mount } from 'enzyme';
+import { render } from '@testing-library/react';
import useLock from '../src/hooks/useLock';
import { injectRunAllTimers } from './utils/common';
@@ -8,6 +8,7 @@ describe('Hooks', () => {
it('useLock', () => {
jest.useFakeTimers();
+ const clearTimeoutSpy = jest.spyOn(window, 'clearTimeout');
let outSetLock: (newLock: boolean) => void;
@@ -17,12 +18,15 @@ describe('Hooks', () => {
return null;
};
- const wrapper = mount();
+ const { unmount } = render();
+ clearTimeoutSpy.mockReset();
outSetLock(true);
- wrapper.unmount();
+ unmount();
- expect(window.clearTimeout).toHaveBeenCalled();
+ expect(clearTimeoutSpy).toHaveBeenCalled();
+
+ clearTimeoutSpy.mockRestore();
jest.runAllTimers();
jest.useRealTimers();
diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx
index d27273118..37237d3e3 100644
--- a/tests/Select.test.tsx
+++ b/tests/Select.test.tsx
@@ -1,4 +1,5 @@
import { mount, render } from 'enzyme';
+import { render as testingRender, fireEvent } from '@testing-library/react';
import KeyCode from 'rc-util/lib/KeyCode';
import { spyElementPrototype } from 'rc-util/lib/test/domHook';
import { resetWarned } from 'rc-util/lib/warning';
@@ -1151,7 +1152,7 @@ describe('Select.Basic', () => {
const onChildClick = jest.fn();
const onMouseDown = jest.fn();
- const wrapper = mount(
+ const { container } = testingRender(
,
);
- toggleOpen(wrapper);
- wrapper.find('div#dropdown-custom-node').simulate('mousedown');
- wrapper.find('div#dropdown-custom-node').simulate('click');
+ // Open
+ fireEvent.mouseDown(container.querySelector('.rc-select-selector'));
+
+ fireEvent.mouseDown(container.querySelector('div#dropdown-custom-node'));
+ fireEvent.click(container.querySelector('div#dropdown-custom-node'));
expect(onMouseDown).toHaveBeenCalled();
expect(onChildClick).toHaveBeenCalled();
@@ -1178,7 +1181,7 @@ describe('Select.Basic', () => {
jest.runAllTimers();
- expect(wrapper.find('input').instance()).toBe(document.activeElement);
+ expect(container.querySelector('input')).toBe(document.activeElement);
jest.useRealTimers();
});