Skip to content

Commit 3733dfe

Browse files
authored
test: fix site test infinite loop in Jest --watch mode + simplify test (#11312)
1 parent 1808945 commit 3733dfe

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

jest.config.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ const ignorePatterns = [
3232
export default {
3333
rootDir: fileURLToPath(new URL('.', import.meta.url)),
3434
verbose: true,
35+
// Default 5s timeout often fails on Windows :s,
36+
// see https://github.com/facebook/docusaurus/pull/8259
37+
testTimeout: 15000,
3538
setupFiles: ['./jest/setup.js'],
3639
testEnvironmentOptions: {
3740
url: 'https://docusaurus.io/',
3841
},
3942
testEnvironment: 'node',
4043
testPathIgnorePatterns: ignorePatterns,
41-
// Default 5s timeout often fails on Windows :s,
42-
// see https://github.com/facebook/docusaurus/pull/8259
43-
testTimeout: 15000,
44+
watchPathIgnorePatterns: ['/\\.docusaurus'],
4445
coveragePathIgnorePatterns: [
4546
...ignorePatterns,
4647
// We also ignore all package entry points

packages/docusaurus/src/server/__tests__/__snapshots__/site.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`load loads props for site with custom i18n path 1`] = `
3+
exports[`load loads props for site 1`] = `
44
{
55
"baseUrl": "/",
66
"codeTranslations": {},

packages/docusaurus/src/server/__tests__/site.test.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,22 @@
66
*/
77

88
import path from 'path';
9-
import {mergeWithCustomize} from 'webpack-merge';
109
import {loadSetup} from './testUtils';
11-
import type {Props} from '@docusaurus/types';
12-
import type {DeepPartial} from 'utility-types';
1310

1411
describe('load', () => {
15-
it('loads props for site with custom i18n path', async () => {
12+
it('loads props for site', async () => {
1613
const site = await loadSetup('custom-i18n-site');
1714
expect(site.props).toMatchSnapshot();
18-
const site2 = await loadSetup('custom-i18n-site', {locale: 'zh-Hans'});
19-
expect(site2.props).toEqual(
20-
mergeWithCustomize<DeepPartial<Props>>({
21-
customizeArray(a, b, key) {
22-
return ['routesPaths', 'plugins'].includes(key) ? b : undefined;
23-
},
24-
})(site.props, {
15+
});
16+
17+
it('loads props for site - custom i18n path', async () => {
18+
const site = await loadSetup('custom-i18n-site', {locale: 'zh-Hans'});
19+
expect(site.props).toEqual(
20+
expect.objectContaining({
2521
baseUrl: '/zh-Hans/',
26-
i18n: {
22+
i18n: expect.objectContaining({
2723
currentLocale: 'zh-Hans',
28-
},
24+
}),
2925
localizationDir: path.join(
3026
__dirname,
3127
'__fixtures__/custom-i18n-site/i18n/zh-Hans-custom',
@@ -35,14 +31,14 @@ describe('load', () => {
3531
'__fixtures__/custom-i18n-site/build/zh-Hans',
3632
),
3733
routesPaths: ['/zh-Hans/404.html'],
38-
siteConfig: {
34+
siteConfig: expect.objectContaining({
3935
baseUrl: '/zh-Hans/',
40-
},
36+
}),
4137
siteStorage: {
4238
namespace: '',
4339
type: 'localStorage',
4440
},
45-
plugins: site2.props.plugins,
41+
plugins: site.props.plugins,
4642
}),
4743
);
4844
});

0 commit comments

Comments
 (0)