chore: fix flaky tests (#8259)

This commit is contained in:
Sébastien Lorber 2022-10-28 11:46:54 +02:00 committed by GitHub
parent 5baa56b4bf
commit 9f4d2e7136
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 10 deletions

3
jest.config.mjs vendored
View file

@ -36,6 +36,9 @@ export default {
}, },
testEnvironment: 'node', testEnvironment: 'node',
testPathIgnorePatterns: ignorePatterns, testPathIgnorePatterns: ignorePatterns,
// Default 5s timeout often fails on Windows :s,
// 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

View file

@ -12,7 +12,7 @@ exports[`error prints objects 1`] = `
"[ERROR] 1,2,3", "[ERROR] 1,2,3",
], ],
[ [
"[ERROR] Sat Nov 13 2021 00:00:00 GMT+0000 (Coordinated Universal Time)", "[ERROR] Sat, 13 Nov 2021 00:00:00 GMT",
], ],
] ]
`; `;
@ -29,7 +29,7 @@ exports[`info prints objects 1`] = `
"[INFO] 1,2,3", "[INFO] 1,2,3",
], ],
[ [
"[INFO] Sat Nov 13 2021 00:00:00 GMT+0000 (Coordinated Universal Time)", "[INFO] Sat, 13 Nov 2021 00:00:00 GMT",
], ],
] ]
`; `;
@ -46,7 +46,7 @@ exports[`success prints objects 1`] = `
"[SUCCESS] 1,2,3", "[SUCCESS] 1,2,3",
], ],
[ [
"[SUCCESS] Sat Nov 13 2021 00:00:00 GMT+0000 (Coordinated Universal Time)", "[SUCCESS] Sat, 13 Nov 2021 00:00:00 GMT",
], ],
] ]
`; `;
@ -63,7 +63,7 @@ exports[`warn prints objects 1`] = `
"[WARNING] 1,2,3", "[WARNING] 1,2,3",
], ],
[ [
"[WARNING] Sat Nov 13 2021 00:00:00 GMT+0000 (Coordinated Universal Time)", "[WARNING] Sat, 13 Nov 2021 00:00:00 GMT",
], ],
] ]
`; `;

View file

@ -60,6 +60,9 @@ function stringify(msg: unknown): string {
if (String(msg) === '[object Object]') { if (String(msg) === '[object Object]') {
return JSON.stringify(msg); return JSON.stringify(msg);
} }
if (msg instanceof Date) {
return msg.toUTCString();
}
return String(msg); return String(msg);
} }

View file

@ -34,8 +34,6 @@ import type {
import type {LoadContext} from '@docusaurus/types'; import type {LoadContext} from '@docusaurus/types';
import type {Optional} from 'utility-types'; import type {Optional} from 'utility-types';
jest.setTimeout(15000);
const fixtureDir = path.join(__dirname, '__fixtures__'); const fixtureDir = path.join(__dirname, '__fixtures__');
const createFakeDocFile = ({ const createFakeDocFile = ({

View file

@ -5,15 +5,11 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
import {jest} from '@jest/globals';
import path from 'path'; import path from 'path';
import fs from 'fs-extra'; import fs from 'fs-extra';
import _ from 'lodash'; import _ from 'lodash';
import {extractThemeCodeMessages} from '../../src/utils'; import {extractThemeCodeMessages} from '../../src/utils';
// Seems the 5s default timeout fails sometimes
jest.setTimeout(15000);
describe('theme translations', () => { describe('theme translations', () => {
it('has base messages files contain EXACTLY all the translations extracted from the theme. Please run "yarn workspace @docusaurus/theme-translations update" to keep base messages files up-to-date', async () => { it('has base messages files contain EXACTLY all the translations extracted from the theme. Please run "yarn workspace @docusaurus/theme-translations update" to keep base messages files up-to-date', async () => {
const baseMessagesDirPath = path.join(__dirname, '../base'); const baseMessagesDirPath = path.join(__dirname, '../base');