diff --git a/jest.config.ts b/jest.config.ts deleted file mode 100644 index 846e9fd64..000000000 --- a/jest.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -const { readdirSync } = require('fs'); -const { join } = require('path'); - -const pkgList = readdirSync(join(__dirname, './packages')).filter( - (pkg: string) => pkg.charAt(0) !== '.' -); - -const moduleNameMapper = { - '^react$': require.resolve('react'), - '^.+\\.svg$': require.resolve('jest-svg-transformer'), - '\\.(css|less|sass|scss)$': require.resolve('identity-obj-proxy'), -}; - -pkgList.forEach((shortName: string) => { - const name = `@oceanbase/${shortName}`; - moduleNameMapper[name] = join(__dirname, `./packages/${shortName}/src`); -}); - -module.exports = { - testEnvironment: 'jsdom', - transform: { - '^.+\\.(ts|tsx)?$': 'ts-jest', - '^.+\\.(js|jsx)?$': 'babel-jest', - }, - transformIgnorePatterns: [`/node_modules/(?!${[].join('|')})`], - moduleNameMapper, - setupFilesAfterEnv: ['./tests/setupTests.ts'], -}; diff --git a/package.json b/package.json index b224a5b14..4ab688425 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,9 @@ "site:deploy": "gh-pages -d site", "postpublish": "npm run sync:other-npm", "sync:other-npm": "node -e 'require(\"./scripts/sync-cnpm-and-tnpm\")()'", - "test": "NODE_OPTIONS=--max_old_space_size=4096 cross-env TZ=UTC jest", - "test:coverage": "NODE_OPTIONS=--max_old_space_size=4096 cross-env TZ=UTC TEST_LOG=none jest --coverage", - "test:update": "NODE_OPTIONS=--max_old_space_size=4096 cross-env TZ=UTC jest --updateSnapshot", + "test": "cross-env vitest", + "test:coverage": "cross-env TEST_LOG=none vitest --coverage", + "test:update": "cross-env vitest -u", "lint": "eslint --cache --ext .js,.jsx,.ts,.tsx", "lint:fix": "eslint --cache --ext .js,.jsx,.ts,.tsx --fix --format=pretty", "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,less,md,json}\"", @@ -60,14 +60,13 @@ "@testing-library/react": "^14.2.1", "@testing-library/react-hooks": "^8.0.1", "@testing-library/user-event": "^14.5.2", - "@types/jest": "^29.5.12", "@types/lodash": "^4.14.202", "@types/node": "^20.11.25", "@types/react": "^18.2.64", "@umijs/fabric": "^4.0.1", "@umijs/test": "^4.1.2", "@vercel/analytics": "^1.2.2", - "antd": "^5.15.1", + "antd": "^5.15.0", "antd-style": "^3.6.1", "antd-token-previewer": "^2.0.8", "babel-jest": "^29.7.0", @@ -86,17 +85,12 @@ "husky": "^9.0.11", "identity-obj-proxy": "^3.0.0", "isomorphic-fetch": "^3.0.0", - "jest": "^29.7.0", - "jest-canvas-mock": "^2.5.2", "jest-environment-jsdom": "^29.7.0", - "jest-fetch-mock": "^3.0.3", - "jest-svg-transformer": "^1.0.0", "jsonml-to-react-element": "^1.1.11", "jsonml.js": "^0.1.0", "lerna": "^8.1.2", "lint-staged": "^15.2.2", "lodash": "^4.17.21", - "lz-string": "^1.5.0", "mockdate": "^3.0.5", "prettier": "^3.2.5", "prismjs": "^1.29.0", @@ -115,13 +109,12 @@ "react-intl": "^6.6.2", "react-router-dom": "^6.22.3", "runscript": "^1.6.0", - "svg-jest": "^1.0.1", - "sylvanas": "^0.6.1", - "ts-jest": "^29.1.2", "ts-node": "^10.9.2", "typescript": "^5.4.2", "vanilla-jsoneditor": "^0.21.6", - "web-vitals": "^3.5.2", - "yorkie": "^2.0.0" + "vitest": "^1.3.1", + "vitest-canvas-mock": "^0.3.3", + "vitest-fetch-mock": "^0.2.2", + "web-vitals": "^3.5.2" } } diff --git a/packages/charts/src/Area/__tests__/__snapshots__/ref.test.tsx.snap b/packages/charts/src/Area/__tests__/__snapshots__/ref.test.tsx.snap deleted file mode 100644 index 5594283d9..000000000 --- a/packages/charts/src/Area/__tests__/__snapshots__/ref.test.tsx.snap +++ /dev/null @@ -1,26 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Area ref ref 1`] = ` -
-
- -
- - -`; diff --git a/packages/charts/src/DualAxes/__tests__/__snapshots__/ref.test.tsx.snap b/packages/charts/src/DualAxes/__tests__/__snapshots__/ref.test.tsx.snap deleted file mode 100644 index 62365b71f..000000000 --- a/packages/charts/src/DualAxes/__tests__/__snapshots__/ref.test.tsx.snap +++ /dev/null @@ -1,26 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`DualAxes ref ref 1`] = ` -
-
- -
- - -`; diff --git a/packages/charts/src/Line/__tests__/__snapshots__/ref.test.tsx.snap b/packages/charts/src/Line/__tests__/__snapshots__/ref.test.tsx.snap deleted file mode 100644 index 472492495..000000000 --- a/packages/charts/src/Line/__tests__/__snapshots__/ref.test.tsx.snap +++ /dev/null @@ -1,26 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Line ref ref 1`] = ` -
-
- -
- - -`; diff --git a/packages/charts/src/Pie/__tests__/__snapshots__/donut.test.tsx.snap b/packages/charts/src/Pie/__tests__/__snapshots__/donut.test.tsx.snap deleted file mode 100644 index 43467c8ae..000000000 --- a/packages/charts/src/Pie/__tests__/__snapshots__/donut.test.tsx.snap +++ /dev/null @@ -1,91 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`donut floor number 1`] = ` -
-
- -
-
- 总数 -
-
-
-
- 21.16 -
-
-
- - -`; - -exports[`donut statistic title and content formatter 1`] = ` -
-
- -
-
- custom title -
-
-
-
- custom content -
-
-
- - -`; diff --git a/packages/charts/vitest.config.ts b/packages/charts/vitest.config.ts new file mode 100644 index 000000000..132a51652 --- /dev/null +++ b/packages/charts/vitest.config.ts @@ -0,0 +1,4 @@ +import { defineProject, mergeConfig } from 'vitest/config'; +import configShared from '../../vitest.config'; + +export default mergeConfig(configShared, defineProject({})); diff --git a/packages/codemod/vitest.config.ts b/packages/codemod/vitest.config.ts new file mode 100644 index 000000000..132a51652 --- /dev/null +++ b/packages/codemod/vitest.config.ts @@ -0,0 +1,4 @@ +import { defineProject, mergeConfig } from 'vitest/config'; +import configShared from '../../vitest.config'; + +export default mergeConfig(configShared, defineProject({})); diff --git a/packages/design/src/badge/__tests__/__snapshots__/index.test.tsx.snap b/packages/design/src/badge/__tests__/__snapshots__/index.test.tsx.snap index 27be679dd..12702de4f 100644 --- a/packages/design/src/badge/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/design/src/badge/__tests__/__snapshots__/index.test.tsx.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Badge status custom icon 1`] = ` +exports[`Badge > status custom icon 1`] = ` `; -exports[`Badge status dot 1`] = ` +exports[`Badge > status dot 1`] = ` @@ -51,7 +51,7 @@ exports[`Badge status dot 1`] = ` `; -exports[`Badge status icon 1`] = ` +exports[`Badge > status icon 1`] = ` spin.indicator should work 1`] = `
`; -exports[`ConfigProvider spin spin.indicator should work in nested ConfigProvider 1`] = ` +exports[`ConfigProvider spin > spin.indicator should work in nested ConfigProvider 1`] = `
`; +exports[`ConfigProvider styleProviderProps > ConfigProvider styleProviderProps.hashPriority 1`] = `
`; diff --git a/packages/design/src/config-provider/__tests__/navigate.test.tsx b/packages/design/src/config-provider/__tests__/navigate.test.tsx index dc0d43e40..56fce9415 100644 --- a/packages/design/src/config-provider/__tests__/navigate.test.tsx +++ b/packages/design/src/config-provider/__tests__/navigate.test.tsx @@ -1,7 +1,7 @@ import React, { useContext } from 'react'; import { BrowserRouter, useNavigate } from 'react-router-dom'; import { render } from '@testing-library/react'; -import ConfigProvider from '..'; +import { ConfigProvider } from '@oceanbase/design'; describe('ConfigProvider navigate', () => { it('navigate should work', () => { diff --git a/packages/design/src/descriptions/__tests__/__snapshots__/index.test.tsx.snap b/packages/design/src/descriptions/__tests__/__snapshots__/index.test.tsx.snap index 0519fb244..7e6f830a2 100644 --- a/packages/design/src/descriptions/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/design/src/descriptions/__tests__/__snapshots__/index.test.tsx.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Descriptions contentProps should work for Descriptions.Item 1`] = ` +exports[`Descriptions > contentProps should work for Descriptions.Item 1`] = `
@@ -51,7 +51,7 @@ exports[`Descriptions contentProps should work for Descriptions.Item 1`] = `
`; -exports[`Descriptions contentProps should work for items 1`] = ` +exports[`Descriptions > contentProps should work for items 1`] = `
@@ -102,7 +102,7 @@ exports[`Descriptions contentProps should work for items 1`] = `
`; -exports[`Descriptions remove colon for vertical layout by default for Descriptions.Item 1`] = ` +exports[`Descriptions > remove colon for vertical layout by default for Descriptions.Item 1`] = `
@@ -302,7 +302,7 @@ exports[`Descriptions remove colon for vertical layout by default for Descriptio
`; -exports[`Descriptions remove colon for vertical layout by default for items 1`] = ` +exports[`Descriptions > remove colon for vertical layout by default for items 1`] = `
@@ -502,7 +502,7 @@ exports[`Descriptions remove colon for vertical layout by default for items 1`]
`; -exports[`Descriptions render for Descriptions.Item 1`] = ` +exports[`Descriptions > render for Descriptions.Item 1`] = `
@@ -649,7 +649,7 @@ exports[`Descriptions render for Descriptions.Item 1`] = `
`; -exports[`Descriptions render for items 1`] = ` +exports[`Descriptions > render for items 1`] = `
diff --git a/packages/design/src/drawer/__tests__/__snapshots__/index.test.tsx.snap b/packages/design/src/drawer/__tests__/__snapshots__/index.test.tsx.snap index 1deda45c6..61f879b0b 100644 --- a/packages/design/src/drawer/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/design/src/drawer/__tests__/__snapshots__/index.test.tsx.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Drawer render correctly 1`] = ` +exports[`Drawer > render correctly 1`] = `
`; -exports[`Drawer render with confirmLoading and okButtonProps 1`] = ` +exports[`Drawer > render with confirmLoading and okButtonProps 1`] = `