Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Branch] improve(test): Migrate from jest to vitest #483

Merged
merged 5 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions jest.config.ts

This file was deleted.

23 changes: 8 additions & 15 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 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}\"",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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"
}
}
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
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[`Descriptions contentProps should work for Descriptions.Item 1`] = `
exports[`Descriptions > contentProps should work for Descriptions.Item 1`] = `
<div
class="ant-descriptions"
>
Expand Down Expand Up @@ -51,7 +51,7 @@ exports[`Descriptions contentProps should work for Descriptions.Item 1`] = `
</div>
`;

exports[`Descriptions contentProps should work for items 1`] = `
exports[`Descriptions > contentProps should work for items 1`] = `
<div
class="ant-descriptions"
>
Expand Down Expand Up @@ -102,7 +102,7 @@ exports[`Descriptions contentProps should work for items 1`] = `
</div>
`;

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`] = `
<div
class="ant-descriptions"
>
Expand Down Expand Up @@ -302,7 +302,7 @@ exports[`Descriptions remove colon for vertical layout by default for Descriptio
</div>
`;

exports[`Descriptions remove colon for vertical layout by default for items 1`] = `
exports[`Descriptions > remove colon for vertical layout by default for items 1`] = `
<div
class="ant-descriptions"
>
Expand Down Expand Up @@ -502,7 +502,7 @@ exports[`Descriptions remove colon for vertical layout by default for items 1`]
</div>
`;

exports[`Descriptions render for Descriptions.Item 1`] = `
exports[`Descriptions > render for Descriptions.Item 1`] = `
<div
class="ant-descriptions"
>
Expand Down Expand Up @@ -649,7 +649,7 @@ exports[`Descriptions render for Descriptions.Item 1`] = `
</div>
`;

exports[`Descriptions render for items 1`] = `
exports[`Descriptions > render for items 1`] = `
<div
class="ant-descriptions"
>
Expand Down
Loading
Loading