Skip to content

Commit

Permalink
Revert "Revert "chore: migrate to vitest (ant-design#42506)" (ant-des…
Browse files Browse the repository at this point in the history
…ign#42900)"

This reverts commit 7322aa6.
  • Loading branch information
Dunqing committed Aug 16, 2023
1 parent 83e3b52 commit 8768625
Show file tree
Hide file tree
Showing 444 changed files with 3,096 additions and 65,363 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Expand Up @@ -21,4 +21,3 @@ coverage
**/*.d.ts
# Scripts
scripts/previewEditor/**/*
jest-stare
27 changes: 18 additions & 9 deletions .eslintrc.js
Expand Up @@ -3,7 +3,7 @@ module.exports = {
'airbnb',
'prettier',
'plugin:compat/recommended',
'plugin:jest/recommended',
'plugin:vitest/recommended',
'plugin:react/recommended',
'plugin:import/typescript',
'plugin:markdown/recommended',
Expand All @@ -12,7 +12,6 @@ module.exports = {
browser: true,
node: true,
jasmine: true,
jest: true,
es6: true,
},
settings: {
Expand All @@ -25,7 +24,15 @@ module.exports = {
},
},
parser: '@typescript-eslint/parser',
plugins: ['react', '@babel', 'jest', '@typescript-eslint', 'react-hooks', 'unicorn', 'markdown'],
plugins: [
'react',
'@babel',
'vitest',
'@typescript-eslint',
'react-hooks',
'unicorn',
'markdown',
],
// https://github.com/typescript-eslint/typescript-eslint/issues/46#issuecomment-470486034
overrides: [
{
Expand Down Expand Up @@ -159,8 +166,10 @@ module.exports = {
'scripts/**',
'**/*.test.js',
'**/__tests__/*',
'__mocks__/**',
'*.config.js',
'**/*.md',
'vitest*config.ts',
],
},
],
Expand All @@ -186,12 +195,12 @@ module.exports = {
'no-restricted-globals': 0,
'max-classes-per-file': 0,

'jest/no-test-callback': 0,
'jest/expect-expect': 0,
'jest/no-done-callback': 0,
'jest/valid-title': 0,
'jest/no-conditional-expect': 0,
'jest/no-standalone-expect': 0,
'vitest/prefer-to-be': 0,
'vitest/expect-expect': 0,
'vitest/no-done-callback': 0,
'vitest/valid-title': 0,
'vitest/no-conditional-expect': 0,
'vitest/no-standalone-expect': 0,

'unicorn/better-regex': 2,
'unicorn/prefer-string-trim-start-end': 2,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Expand Up @@ -191,7 +191,7 @@ jobs:
# dom test
- name: dom test
if: ${{ matrix.module == 'dom' }}
run: npm test -- --maxWorkers=2 --shard=${{matrix.shard}} --coverage
run: npm test -- --shard=${{matrix.shard}} --coverage

- name: persist coverages
if: ${{ matrix.module == 'dom' && matrix.react == '17' }}
Expand Down Expand Up @@ -347,7 +347,7 @@ jobs:
- name: test
# lib only run in master branch not in pull request
if: ${{ github.event_name != 'pull_request' || matrix.module != 'lib' }}
run: npm test -- --maxWorkers=2 --shard=${{matrix.shard}}
run: npm test -- --shard=${{matrix.shard}}
env:
LIB_DIR: ${{ matrix.module }}
needs: compile
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -60,7 +60,6 @@ components/version/token-meta.json
# Image snapshot diff
__diff_output__/
__image_snapshots__/
/jest-stare
/imageSnapshots
/imageDiffSnapshots

Expand Down
23 changes: 0 additions & 23 deletions .jest.image.js

This file was deleted.

70 changes: 0 additions & 70 deletions .jest.js

This file was deleted.

19 changes: 0 additions & 19 deletions .jest.node.js

This file was deleted.

21 changes: 0 additions & 21 deletions .jest.site.js

This file was deleted.

@@ -1,16 +1,17 @@
import type { TriggerProps, TriggerRef } from '@rc-component/trigger';
import MockTrigger from '@rc-component/trigger/lib/mock';
import type { TriggerProps } from '@rc-component/trigger';
import MockTrigger from '@rc-component/trigger/es/mock';
import * as React from 'react';
import { TriggerMockContext } from '../../shared/demoTestContext';
import { TriggerMockContext } from '../../tests/shared/demoTestContext';

let OriginTrigger = jest.requireActual('@rc-component/trigger');
OriginTrigger = OriginTrigger.default ?? OriginTrigger;
const { default: OriginTrigger } = await vi.importActual<typeof import('@rc-component/trigger')>(
'@rc-component/trigger',
);

const ForwardTrigger = React.forwardRef<TriggerRef, TriggerProps>((props, ref) => {

Check failure on line 10 in __mocks__/@rc-component/trigger.tsx

View workflow job for this annotation

GitHub Actions / lint

Cannot find name 'TriggerRef'.
const context = React.useContext(TriggerMockContext);

const mergedPopupVisible = context?.popupVisible ?? props.popupVisible;
(global as any).triggerProps = props;
globalThis.triggerProps = props;

const mergedProps: TriggerProps = {
...props,
Expand Down
File renamed without changes.
@@ -1,15 +1,9 @@
import React from 'react';
import type { PortalProps, PortalRef } from 'rc-util/lib/Portal';
import { TriggerMockContext } from '../../../shared/demoTestContext';

Check failure on line 2 in __mocks__/rc-util/es/Portal.tsx

View workflow job for this annotation

GitHub Actions / lint

Cannot find module '../../../shared/demoTestContext' or its corresponding type declarations.

let OriginPortal = jest.requireActual('rc-util/lib/Portal');
OriginPortal = OriginPortal.default ?? OriginPortal;

interface MockPortalProps {
children?: React.ReactNode
}

class MockPortal extends React.Component<MockPortalProps> {
class MockPortal extends React.Component<{ children?: React.ReactNode }> {
container: boolean;

static contextType = TriggerMockContext;
Expand Down Expand Up @@ -40,4 +34,4 @@ const CustomPortal = React.forwardRef<PortalRef, PortalProps | MockPortalProps>(
return <MockPortal {...props} />;
});

export default CustomPortal;
export default CustomPortal;
3 changes: 3 additions & 0 deletions __mocks__/rc-virtual-list.ts
@@ -0,0 +1,3 @@
import Mock from 'rc-virtual-list/es/mock';

export default Mock;
12 changes: 6 additions & 6 deletions components/__tests__/__snapshots__/index.test.ts.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`antd exports modules correctly 1`] = `
exports[`antd > exports modules correctly 1`] = `
[
"Affix",
"Alert",
Expand Down Expand Up @@ -37,7 +37,9 @@ exports[`antd exports modules correctly 1`] = `
"List",
"Mentions",
"Menu",
"message",
"Modal",
"notification",
"Pagination",
"Popconfirm",
"Popover",
Expand All @@ -59,6 +61,7 @@ exports[`antd exports modules correctly 1`] = `
"Table",
"Tabs",
"Tag",
"theme",
"TimePicker",
"Timeline",
"Tooltip",
Expand All @@ -68,10 +71,7 @@ exports[`antd exports modules correctly 1`] = `
"TreeSelect",
"Typography",
"Upload",
"Watermark",
"message",
"notification",
"theme",
"version",
"Watermark",
]
`;
4 changes: 2 additions & 2 deletions components/__tests__/__snapshots__/setup.test.tsx.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`SetUp.Test diff of React 18 & React 17 1`] = `
exports[`SetUp.Test > diff of React 18 & React 17 1`] = `
NodeList [
<div>
bamboo
Expand Down
3 changes: 2 additions & 1 deletion components/__tests__/index.test.ts
@@ -1,6 +1,7 @@
import * as antd from '..';

const OLD_NODE_ENV = process.env.NODE_ENV;
process.env.NODE_ENV = 'development';
const antd = require('..');

describe('antd', () => {
afterAll(() => {
Expand Down

0 comments on commit 8768625

Please sign in to comment.