fix: npm install fail need --legacy-peer-deps

This commit is contained in:
baorong
2026-03-15 15:43:23 +08:00
parent ccaf67076e
commit 6d4e1289a3
5 changed files with 18 additions and 15 deletions
+5 -5
View File
@@ -26,12 +26,12 @@
},
"devDependencies": {
"@testing-library/jest-dom": "^6.1.1",
"@testing-library/react": "^14.0.0",
"@testing-library/react": "^16.0.0",
"@types/jest": "^29.5.3",
"@types/react": "19.2.14",
"@types/react-dom": "^19.2.3",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"@umijs/test": "^4.6.32",
"eslint": "^8.47.0",
"eslint-config-prettier": "^10.1.8",
@@ -41,10 +41,10 @@
"eslint-plugin-prettier": "^5.1.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-unused-imports": "^2.0.0",
"eslint-plugin-unused-imports": "^4.4.1",
"jest": "^29.6.1",
"mockjs": "^1.1.0",
"prettier": "^2.8.8",
"prettier": "^3.0.0",
"prettier-plugin-organize-imports": "^3.2.2",
"prettier-plugin-packagejson": "^2.4.3",
"ts-jest": "^29.1.0",
+8 -5
View File
@@ -1,9 +1,9 @@
import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';
import DropOption from './DropOption';
// Mock antd Dropdown to expose menu items for testing
jest.mock('antd', () => {
const React = require('react');
return {
Dropdown: ({ menu, children }: any) =>
React.createElement(
@@ -31,10 +31,13 @@ jest.mock('antd', () => {
};
});
jest.mock('@ant-design/icons', () => ({
BarsOutlined: () => React.createElement('span', null, 'Bars'),
DownOutlined: () => React.createElement('span', null, 'Down'),
}));
jest.mock('@ant-design/icons', () => {
const React = require('react');
return {
BarsOutlined: () => React.createElement('span', null, 'Bars'),
DownOutlined: () => React.createElement('span', null, 'Down'),
};
});
test('renders default trigger when no children provided', () => {
render(<DropOption menuOptions={[]} />);
+2 -2
View File
@@ -74,9 +74,9 @@ export default function TopbarControls({ goProfile, onLogout }: Props) {
const handleProfileClick = (key: string) => {
if (key === 'profile') {
goProfile && goProfile();
goProfile?.();
} else if (key === 'logout') {
onLogout && onLogout();
onLogout?.();
}
};
+1 -1
View File
@@ -74,7 +74,7 @@ export default function SortModal({ open, menus, onCancel, onConfirm }: Props) {
route: r.route || '/',
sort: r.sort,
children: r.children ? buildMenuTree(r.children) : undefined,
} as MenuItem),
}) as MenuItem,
);
};
+2 -2
View File
@@ -41,7 +41,7 @@ describe('api', () => {
const err = new Error('net fail');
(global.fetch as jest.Mock).mockRejectedValue(err);
const spy = jest.spyOn(message, 'error') as jest.SpyInstance<any, any>;
spy.mockImplementation(() => ({} as any));
spy.mockImplementation(() => ({}) as any);
await expect(api('/x')).rejects.toThrow('net fail');
expect(spy).toBeCalledWith('net fail');
spy.mockRestore();
@@ -54,7 +54,7 @@ describe('api', () => {
json: async () => ({}),
});
const spy = jest.spyOn(message, 'error') as jest.SpyInstance<any, any>;
spy.mockImplementation(() => ({} as any));
spy.mockImplementation(() => ({}) as any);
await expect(api('/x')).rejects.toThrow('Invalid API response format');
expect(spy).toBeCalledWith('Invalid API response format');
spy.mockRestore();