Skip to content

Commit

Permalink
improve(test): Migrate from jest to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
dengfuping committed Feb 19, 2024
1 parent a51be6a commit 7a832ae
Show file tree
Hide file tree
Showing 48 changed files with 2,565 additions and 3,307 deletions.
28 changes: 0 additions & 28 deletions jest.config.ts

This file was deleted.

41 changes: 16 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 TZ=UTC vitest",
"test:coverage": "cross-env TZ=UTC TEST_LOG=none vitest --coverage",
"test:update": "cross-env TZ=UTC 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}\"",
Expand Down Expand Up @@ -60,23 +60,20 @@
"@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.16",
"@types/react": "^18.2.54",
"@types/node": "^20.11.19",
"@types/react": "^18.2.56",
"@umijs/fabric": "^4.0.1",
"@umijs/test": "^4.1.1",
"@vercel/analytics": "^1.1.3",
"antd": "^5.14.0",
"@vercel/analytics": "^1.2.1",
"antd": "^5.14.1",
"antd-style": "^3.6.1",
"antd-token-previewer": "^2.0.5",
"babel-jest": "^29.7.0",
"antd-token-previewer": "^2.0.8",
"classnames": "^2.5.1",
"copy-to-clipboard": "^3.3.3",
"cross-env": "^7.0.3",
"dayjs": "^1.11.10",
"dumi": "^2.2.17",
"eslint-plugin-jest": "^27.6.3",
"execa": "^5.1.1",
"father": "^4.4.0",
"fs-extra": "^11.2.0",
Expand All @@ -86,22 +83,17 @@
"husky": "^8.0.3",
"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",
"rc-checkbox": "^3.1.0",
"rc-drawer": "^7.0.0",
"rc-drawer": "^7.1.0",
"rc-footer": "^0.6.8",
"rc-resize-observer": "^1.4.0",
"rc-segmented": "^2.3.0",
Expand All @@ -111,17 +103,16 @@
"react-color": "^2.19.3",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^18.2.0",
"react-fast-marquee": "^1.6.3",
"react-fast-marquee": "^1.6.4",
"react-intl": "^6.6.2",
"react-router-dom": "^6.22.0",
"react-router-dom": "^6.22.1",
"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.3.3",
"vanilla-jsoneditor": "^0.21.5",
"web-vitals": "^3.5.2",
"yorkie": "^2.0.0"
"vanilla-jsoneditor": "^0.21.6",
"vitest": "^1.3.0",
"vitest-canvas-mock": "^0.3.3",
"vitest-fetch-mock": "^0.2.2",
"web-vitals": "^3.5.2"
}
}
26 changes: 0 additions & 26 deletions packages/charts/src/Area/__tests__/__snapshots__/ref.test.tsx.snap

This file was deleted.

This file was deleted.

26 changes: 0 additions & 26 deletions packages/charts/src/Line/__tests__/__snapshots__/ref.test.tsx.snap

This file was deleted.

This file was deleted.

4 changes: 4 additions & 0 deletions packages/charts/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { defineProject, mergeConfig } from 'vitest/config';
import configShared from '../../vitest.config';

export default mergeConfig(configShared, defineProject({}));
4 changes: 4 additions & 0 deletions packages/codemod/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { defineProject, mergeConfig } from 'vitest/config';
import configShared from '../../vitest.config';

export default mergeConfig(configShared, defineProject({}));
Original file line number Diff line number Diff line change
@@ -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`] = `
<span
class="ant-badge ant-badge-status"
style="display: inline-block;"
Expand Down Expand Up @@ -36,7 +36,7 @@ exports[`Badge status custom icon 1`] = `
</span>
`;

exports[`Badge status dot 1`] = `
exports[`Badge > status dot 1`] = `
<span
class="ant-badge ant-badge-status ant-badge-not-a-wrapper"
>
Expand All @@ -51,7 +51,7 @@ exports[`Badge status dot 1`] = `
</span>
`;

exports[`Badge status icon 1`] = `
exports[`Badge > status icon 1`] = `
<span
class="ant-badge ant-badge-status"
style="display: inline-block;"
Expand Down
1 change: 1 addition & 0 deletions packages/design/src/badge/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { render } from '@testing-library/react';
import { describe, it } from 'vitest';
import { Badge } from '@oceanbase/design';
import { TaobaoOutlined } from '@oceanbase/icons';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`ConfigProvider spin spin.indicator should work 1`] = `
exports[`ConfigProvider spin > spin.indicator should work 1`] = `
<div
aria-busy="true"
aria-live="polite"
Expand All @@ -12,7 +12,7 @@ exports[`ConfigProvider spin spin.indicator should work 1`] = `
</div>
`;

exports[`ConfigProvider spin spin.indicator should work in nested ConfigProvider 1`] = `
exports[`ConfigProvider spin > spin.indicator should work in nested ConfigProvider 1`] = `
<div
aria-busy="true"
aria-live="polite"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`ConfigProvider styleProviderProps ConfigProvider styleProviderProps.hashPriority 1`] = `<div />`;
exports[`ConfigProvider styleProviderProps > ConfigProvider styleProviderProps.hashPriority 1`] = `<div />`;
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
Loading

0 comments on commit 7a832ae

Please sign in to comment.