mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-25 17:22:50 +00:00
try to fix tinyglobby
This commit is contained in:
parent
1c13e463a0
commit
f2edb911d8
|
|
@ -5,7 +5,6 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {jest} from '@jest/globals';
|
||||
import fs from 'fs-extra';
|
||||
import tmp from 'tmp-promise';
|
||||
import {getBabelOptions} from '../utils';
|
||||
|
|
@ -45,16 +44,10 @@ const default => {
|
|||
`,
|
||||
});
|
||||
|
||||
const errorMock = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
await expect(
|
||||
extractSourceCodeFileTranslations(sourceCodeFilePath, TestBabelOptions),
|
||||
).rejects.toThrow();
|
||||
|
||||
expect(errorMock).toHaveBeenCalledWith(
|
||||
expect.stringMatching(
|
||||
/Error while attempting to extract Docusaurus translations from source code file at/,
|
||||
),
|
||||
).rejects.toThrow(
|
||||
/Error while attempting to extract Docusaurus translations from source code file at/,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import {
|
|||
type NodePath,
|
||||
type TransformOptions,
|
||||
} from '@babel/core';
|
||||
import {logger} from '@docusaurus/logger';
|
||||
import type {TranslationFileContent} from '@docusaurus/types';
|
||||
|
||||
export type SourceCodeFileTranslations = {
|
||||
|
|
@ -56,7 +57,7 @@ export async function extractSourceCodeFileTranslations(
|
|||
return translations;
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`Error while attempting to extract Docusaurus translations from source code file at path=${sourceCodeFilePath}.`,
|
||||
logger.interpolate`Error while attempting to extract Docusaurus translations from source code file at path=${sourceCodeFilePath}.`,
|
||||
{cause: err as Error},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ describe('extractThemeCodeMessages', () => {
|
|||
await expect(() =>
|
||||
extractThemeCodeMessages([path.join(__dirname, '__fixtures__/theme')]),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(`
|
||||
"
|
||||
Please make sure all theme translations are static!
|
||||
Some warnings were found!
|
||||
"
|
||||
Please make sure all theme translations are static!
|
||||
Some warnings were found!
|
||||
|
||||
Translate content could not be extracted. It has to be a static string and use optional but static props, like <Translate id="my-id" description="my-description">text</Translate>.
|
||||
File: packages/docusaurus-theme-translations/src/__tests__/__fixtures__/theme/index.js at line 4
|
||||
Full code: <Translate>{index}</Translate>
|
||||
"
|
||||
`);
|
||||
Translate content could not be extracted. It has to be a static string and use optional but static props, like <Translate id="my-id" description="my-description">text</Translate>.
|
||||
File: <PROJECT_ROOT>/packages/docusaurus-theme-translations/src/__tests__/__fixtures__/theme/index.js at line 4
|
||||
Full code: <Translate>{index}</Translate>
|
||||
"
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue