Skip to content

Commit 901811b

Browse files
committed
chore: update jest to 28
1 parent 985f1cf commit 901811b

File tree

30 files changed

+1154
-779
lines changed

30 files changed

+1154
-779
lines changed

.jest.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,21 @@ const transformIgnorePatterns = [
1010
const testPathIgnorePatterns = ['/node_modules/', 'node'];
1111

1212
module.exports = {
13-
testURL: 'http://localhost/',
1413
setupFiles: ['./tests/setup.js'],
1514
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'vue', 'md', 'jpg'],
1615
modulePathIgnorePatterns: ['/_site/'],
1716
testPathIgnorePatterns: testPathIgnorePatterns,
1817
transform: {
19-
'^.+\\.(vue|md)$': '<rootDir>/node_modules/vue-jest',
18+
'^.+\\.(vue|md)$': '<rootDir>/node_modules/@vue/vue3-jest',
2019
'^.+\\.(js|jsx)$': '<rootDir>/node_modules/babel-jest',
2120
'^.+\\.(ts|tsx)$': '<rootDir>/node_modules/ts-jest',
2221
'^.+\\.svg$': '<rootDir>/node_modules/jest-transform-stub',
2322
},
2423
testRegex: libDir === 'dist' ? 'demo\\.test\\.js$' : '.*\\.test\\.js$',
2524
moduleNameMapper: {
26-
'^@/(.*)$': '<rootDir>/$1',
27-
'ant-design-vue$': '<rootDir>/components/index.ts',
28-
'ant-design-vue/es': '<rootDir>/components',
25+
'/^@/(.*)$/': '<rootDir>/$1',
26+
'/ant-design-vue$/': '<rootDir>/components/index.ts',
27+
'/ant-design-vue/es/': '<rootDir>/components',
2928
},
3029
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
3130
collectCoverage: process.env.COVERAGE === 'true',
@@ -43,7 +42,11 @@ module.exports = {
4342
'!components/style.js',
4443
'!**/node_modules/**',
4544
],
46-
testEnvironment: 'jest-environment-jsdom-fifteen',
45+
testEnvironment: 'jsdom',
46+
testEnvironmentOptions: {
47+
url: 'http://localhost',
48+
customExportConditions: ['node', 'node-addons'],
49+
},
4750
transformIgnorePatterns,
4851
globals: {
4952
'ts-jest': {

components/anchor/__tests__/Anchor.test.js

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { mount } from '@vue/test-utils';
22
import { ref } from 'vue';
3+
import { sleep } from '../../../tests/utils';
34
import Anchor from '..';
45

56
const { Link } = Anchor;
@@ -8,7 +9,7 @@ let idCounter = 0;
89
const getHashUrl = () => `Anchor-API-${idCounter++}`;
910

1011
describe('Anchor Render', () => {
11-
it('Anchor render perfectly', async done => {
12+
it('Anchor render perfectly', async () => {
1213
const hash = getHashUrl();
1314
const anchor = ref(null);
1415
const activeLink = ref(null);
@@ -29,17 +30,13 @@ describe('Anchor Render', () => {
2930
},
3031
{ sync: false },
3132
);
33+
await sleep();
34+
wrapper.find(`a[href="#${hash}`).trigger('click');
3235

33-
wrapper.vm.$nextTick(() => {
34-
wrapper.find(`a[href="#${hash}`).trigger('click');
35-
36-
setTimeout(() => {
37-
expect(activeLink.value).not.toBe(hash);
38-
done();
39-
}, 1000);
40-
});
36+
await sleep();
37+
expect(activeLink.value).not.toBe(hash);
4138
});
42-
it('Anchor render perfectly for complete href - click', async done => {
39+
it('Anchor render perfectly for complete href - click', async () => {
4340
const currentActiveLink = ref(null);
4441
const wrapper = mount(
4542
{
@@ -58,13 +55,9 @@ describe('Anchor Render', () => {
5855
},
5956
{ sync: false },
6057
);
61-
62-
wrapper.vm.$nextTick(() => {
63-
wrapper.find('a[href="http://www.example.com/#API"]').trigger('click');
64-
65-
expect(currentActiveLink.value).toBe('http://www.example.com/#API');
66-
done();
67-
});
58+
await sleep();
59+
wrapper.find('a[href="http://www.example.com/#API"]').trigger('click');
60+
expect(currentActiveLink.value).toBe('http://www.example.com/#API');
6861
});
6962
/*
7063
it('Anchor render perfectly for complete href - scroll', done => {

components/auto-complete/__tests__/__snapshots__/demo.test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exports[`renders ./components/auto-complete/demo/certain-category.vue correctly
1717
<div class="ant-select certain-category-search ant-select-show-search ant-select-auto-complete ant-select-single ant-select-customize-input ant-select-show-search" style="width: 250px;">
1818
<!---->
1919
<!---->
20-
<div class="ant-select-selector"><span class="ant-select-selection-search"><span class="ant-input-group-wrapper ant-input-group-wrapper-lg ant-input-search ant-input-search-large ant-select-selection-search-input"><span class="ant-input-wrapper ant-input-group"><!----><input placeholder="input here" id="rc_select_TEST_OR_SSR" autocomplete="off" type="search" class="ant-input ant-input-lg" role="combobox" aria-haspopup="listbox" aria-owns="rc_select_TEST_OR_SSR_list" aria-autocomplete="list" aria-controls="rc_select_TEST_OR_SSR_list" aria-activedescendant="rc_select_TEST_OR_SSR_list_0"><span class="ant-input-group-addon"><button class="ant-btn ant-btn-lg ant-input-search-button ant-btn-icon-only" type="button"><span role="img" aria-label="search" class="anticon anticon-search"><svg focusable="false" class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span></button></span></span></span></span>
20+
<div class="ant-select-selector"><span class="ant-select-selection-search"><span class="ant-input-group-wrapper ant-input-search ant-input-search-large ant-select-selection-search-input ant-input-group-wrapper-lg"><span class="ant-input-wrapper ant-input-group"><!----><input placeholder="input here" autocomplete="off" id="rc_select_TEST_OR_SSR" type="search" class="ant-input ant-input-lg" role="combobox" aria-haspopup="listbox" aria-owns="rc_select_TEST_OR_SSR_list" aria-autocomplete="list" aria-controls="rc_select_TEST_OR_SSR_list" aria-activedescendant="rc_select_TEST_OR_SSR_list_0"><span class="ant-input-group-addon"><button class="ant-btn ant-btn-lg ant-input-search-button ant-btn-icon-only" type="button"><span role="img" aria-label="search" class="anticon anticon-search"><svg focusable="false" class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span></button></span></span></span></span>
2121
<!----><span class="ant-select-selection-placeholder"><!----></span>
2222
</div>
2323
<!---->
@@ -67,7 +67,7 @@ exports[`renders ./components/auto-complete/demo/uncertain-category.vue correctl
6767
<div style="width: 300px;" class="ant-select ant-select-show-search ant-select-auto-complete ant-select-single ant-select-customize-input ant-select-show-search">
6868
<!---->
6969
<!---->
70-
<div class="ant-select-selector"><span class="ant-select-selection-search"><span class="ant-input-group-wrapper ant-input-group-wrapper-lg ant-input-search ant-input-search-large ant-input-search-with-button ant-select-selection-search-input"><span class="ant-input-wrapper ant-input-group"><!----><input placeholder="input here" id="rc_select_TEST_OR_SSR" autocomplete="off" type="search" class="ant-input ant-input-lg" role="combobox" aria-haspopup="listbox" aria-owns="rc_select_TEST_OR_SSR_list" aria-autocomplete="list" aria-controls="rc_select_TEST_OR_SSR_list" aria-activedescendant="rc_select_TEST_OR_SSR_list_0"><span class="ant-input-group-addon"><button class="ant-btn ant-btn-primary ant-btn-lg ant-input-search-button" type="button"><!----><span role="img" aria-label="search" class="anticon anticon-search"><svg focusable="false" class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span></button></span></span></span></span>
70+
<div class="ant-select-selector"><span class="ant-select-selection-search"><span class="ant-input-group-wrapper ant-input-search ant-input-search-large ant-input-search-with-button ant-select-selection-search-input ant-input-group-wrapper-lg"><span class="ant-input-wrapper ant-input-group"><!----><input placeholder="input here" autocomplete="off" id="rc_select_TEST_OR_SSR" type="search" class="ant-input ant-input-lg" role="combobox" aria-haspopup="listbox" aria-owns="rc_select_TEST_OR_SSR_list" aria-autocomplete="list" aria-controls="rc_select_TEST_OR_SSR_list" aria-activedescendant="rc_select_TEST_OR_SSR_list_0"><span class="ant-input-group-addon"><button class="ant-btn ant-btn-primary ant-btn-lg ant-input-search-button" type="button"><!----><span role="img" aria-label="search" class="anticon anticon-search"><svg focusable="false" class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span></button></span></span></span></span>
7171
<!----><span class="ant-select-selection-placeholder"><!----></span>
7272
</div>
7373
<!---->

0 commit comments

Comments
 (0)