diff --git a/packages/docusaurus-babel/src/__tests__/babelTranslationsExtractor.test.ts b/packages/docusaurus-babel/src/__tests__/babelTranslationsExtractor.test.ts
index f221bd2350..f38d5650bf 100644
--- a/packages/docusaurus-babel/src/__tests__/babelTranslationsExtractor.test.ts
+++ b/packages/docusaurus-babel/src/__tests__/babelTranslationsExtractor.test.ts
@@ -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/,
);
});
diff --git a/packages/docusaurus-babel/src/babelTranslationsExtractor.ts b/packages/docusaurus-babel/src/babelTranslationsExtractor.ts
index 00ef7a9b6c..9675d1176f 100644
--- a/packages/docusaurus-babel/src/babelTranslationsExtractor.ts
+++ b/packages/docusaurus-babel/src/babelTranslationsExtractor.ts
@@ -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},
);
}
diff --git a/packages/docusaurus-theme-translations/src/__tests__/utils.test.ts b/packages/docusaurus-theme-translations/src/__tests__/utils.test.ts
index 2f8949b55f..3b86d354ad 100644
--- a/packages/docusaurus-theme-translations/src/__tests__/utils.test.ts
+++ b/packages/docusaurus-theme-translations/src/__tests__/utils.test.ts
@@ -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 text.
- File: packages/docusaurus-theme-translations/src/__tests__/__fixtures__/theme/index.js at line 4
- Full code: {index}
- "
- `);
+ Translate content could not be extracted. It has to be a static string and use optional but static props, like text.
+ File: /packages/docusaurus-theme-translations/src/__tests__/__fixtures__/theme/index.js at line 4
+ Full code: {index}
+ "
+ `);
});
});