mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-17 16:47:56 +02:00
test: fix site test infinite loop in Jest --watch mode + simplify test (#11312)
This commit is contained in:
parent
1808945c1f
commit
3733dfee52
3 changed files with 17 additions and 20 deletions
7
jest.config.mjs
vendored
7
jest.config.mjs
vendored
|
@ -32,15 +32,16 @@ const ignorePatterns = [
|
||||||
export default {
|
export default {
|
||||||
rootDir: fileURLToPath(new URL('.', import.meta.url)),
|
rootDir: fileURLToPath(new URL('.', import.meta.url)),
|
||||||
verbose: true,
|
verbose: true,
|
||||||
|
// Default 5s timeout often fails on Windows :s,
|
||||||
|
// see https://github.com/facebook/docusaurus/pull/8259
|
||||||
|
testTimeout: 15000,
|
||||||
setupFiles: ['./jest/setup.js'],
|
setupFiles: ['./jest/setup.js'],
|
||||||
testEnvironmentOptions: {
|
testEnvironmentOptions: {
|
||||||
url: 'https://docusaurus.io/',
|
url: 'https://docusaurus.io/',
|
||||||
},
|
},
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
testPathIgnorePatterns: ignorePatterns,
|
testPathIgnorePatterns: ignorePatterns,
|
||||||
// Default 5s timeout often fails on Windows :s,
|
watchPathIgnorePatterns: ['/\\.docusaurus'],
|
||||||
// see https://github.com/facebook/docusaurus/pull/8259
|
|
||||||
testTimeout: 15000,
|
|
||||||
coveragePathIgnorePatterns: [
|
coveragePathIgnorePatterns: [
|
||||||
...ignorePatterns,
|
...ignorePatterns,
|
||||||
// We also ignore all package entry points
|
// We also ignore all package entry points
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`load loads props for site with custom i18n path 1`] = `
|
exports[`load loads props for site 1`] = `
|
||||||
{
|
{
|
||||||
"baseUrl": "/",
|
"baseUrl": "/",
|
||||||
"codeTranslations": {},
|
"codeTranslations": {},
|
||||||
|
|
|
@ -6,26 +6,22 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {mergeWithCustomize} from 'webpack-merge';
|
|
||||||
import {loadSetup} from './testUtils';
|
import {loadSetup} from './testUtils';
|
||||||
import type {Props} from '@docusaurus/types';
|
|
||||||
import type {DeepPartial} from 'utility-types';
|
|
||||||
|
|
||||||
describe('load', () => {
|
describe('load', () => {
|
||||||
it('loads props for site with custom i18n path', async () => {
|
it('loads props for site', async () => {
|
||||||
const site = await loadSetup('custom-i18n-site');
|
const site = await loadSetup('custom-i18n-site');
|
||||||
expect(site.props).toMatchSnapshot();
|
expect(site.props).toMatchSnapshot();
|
||||||
const site2 = await loadSetup('custom-i18n-site', {locale: 'zh-Hans'});
|
});
|
||||||
expect(site2.props).toEqual(
|
|
||||||
mergeWithCustomize<DeepPartial<Props>>({
|
it('loads props for site - custom i18n path', async () => {
|
||||||
customizeArray(a, b, key) {
|
const site = await loadSetup('custom-i18n-site', {locale: 'zh-Hans'});
|
||||||
return ['routesPaths', 'plugins'].includes(key) ? b : undefined;
|
expect(site.props).toEqual(
|
||||||
},
|
expect.objectContaining({
|
||||||
})(site.props, {
|
|
||||||
baseUrl: '/zh-Hans/',
|
baseUrl: '/zh-Hans/',
|
||||||
i18n: {
|
i18n: expect.objectContaining({
|
||||||
currentLocale: 'zh-Hans',
|
currentLocale: 'zh-Hans',
|
||||||
},
|
}),
|
||||||
localizationDir: path.join(
|
localizationDir: path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
'__fixtures__/custom-i18n-site/i18n/zh-Hans-custom',
|
'__fixtures__/custom-i18n-site/i18n/zh-Hans-custom',
|
||||||
|
@ -35,14 +31,14 @@ describe('load', () => {
|
||||||
'__fixtures__/custom-i18n-site/build/zh-Hans',
|
'__fixtures__/custom-i18n-site/build/zh-Hans',
|
||||||
),
|
),
|
||||||
routesPaths: ['/zh-Hans/404.html'],
|
routesPaths: ['/zh-Hans/404.html'],
|
||||||
siteConfig: {
|
siteConfig: expect.objectContaining({
|
||||||
baseUrl: '/zh-Hans/',
|
baseUrl: '/zh-Hans/',
|
||||||
},
|
}),
|
||||||
siteStorage: {
|
siteStorage: {
|
||||||
namespace: '',
|
namespace: '',
|
||||||
type: 'localStorage',
|
type: 'localStorage',
|
||||||
},
|
},
|
||||||
plugins: site2.props.plugins,
|
plugins: site.props.plugins,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue