diff --git a/jest.config.mjs b/jest.config.mjs index 5e7200416b..d9fc678189 100644 --- a/jest.config.mjs +++ b/jest.config.mjs @@ -80,6 +80,7 @@ export default { }, snapshotSerializers: [ '/jest/snapshotPathNormalizer.ts', + 'jest-serializer-ansi-escapes', 'jest-serializer-react-helmet-async', ], snapshotFormat: { diff --git a/package.json b/package.json index 5c49f3b503..8406a74818 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "image-size": "^1.0.1", "jest": "^28.1.1", "jest-environment-jsdom": "^28.1.1", + "jest-serializer-ansi-escapes": "^2.0.1", "jest-serializer-react-helmet-async": "^1.0.21", "lerna": "^5.1.4", "lerna-changelog": "^2.2.0", diff --git a/packages/docusaurus-logger/src/__tests__/index.test.ts b/packages/docusaurus-logger/src/__tests__/index.test.ts index cea662c1ca..afea246eb6 100644 --- a/packages/docusaurus-logger/src/__tests__/index.test.ts +++ b/packages/docusaurus-logger/src/__tests__/index.test.ts @@ -8,25 +8,31 @@ import {jest} from '@jest/globals'; import logger from '../index'; -// cSpell:ignore mkeep - describe('formatters', () => { it('path', () => { - expect(logger.path('keepAnsi')).toMatchInlineSnapshot(`""keepAnsi""`); + expect(logger.path('keepAnsi')).toMatchInlineSnapshot( + `""keepAnsi""`, + ); }); it('url', () => { expect(logger.url('https://docusaurus.io/keepAnsi')).toMatchInlineSnapshot( - `"https://docusaurus.io/keepAnsi"`, + `"https://docusaurus.io/keepAnsi"`, ); }); it('id', () => { - expect(logger.name('keepAnsi')).toMatchInlineSnapshot(`"keepAnsi"`); + expect(logger.name('keepAnsi')).toMatchInlineSnapshot( + `"keepAnsi"`, + ); }); it('code', () => { - expect(logger.code('keepAnsi')).toMatchInlineSnapshot(`"\`keepAnsi\`"`); + expect(logger.code('keepAnsi')).toMatchInlineSnapshot( + `"\`keepAnsi\`"`, + ); }); it('subdue', () => { - expect(logger.subdue('keepAnsi')).toMatchInlineSnapshot(`"keepAnsi"`); + expect(logger.subdue('keepAnsi')).toMatchInlineSnapshot( + `"keepAnsi"`, + ); }); }); @@ -47,7 +53,7 @@ describe('interpolate', () => { expect( logger.interpolate`(keepAnsi) The package at path=${'packages/docusaurus'} has number=${10} files. name=${'Babel'} is exported here subdue=${'(as a preset)'} that you can with code=${"require.resolve('@docusaurus/core/lib/babel/preset')"}`, ).toMatchInlineSnapshot( - `"(keepAnsi) The package at "packages/docusaurus" has 10 files. Babel is exported here (as a preset) that you can with \`require.resolve('@docusaurus/core/lib/babel/preset')\`"`, + `"(keepAnsi) The package at "packages/docusaurus" has 10 files. Babel is exported here (as a preset) that you can with \`require.resolve('@docusaurus/core/lib/babel/preset')\`"`, ); }); it('interpolates arrays with flags', () => { @@ -59,9 +65,9 @@ describe('interpolate', () => { ]}`, ).toMatchInlineSnapshot(` "(keepAnsi) The following commands are available: - - \`docusaurus start\` - - \`docusaurus build\` - - \`docusaurus deploy\`" + - \`docusaurus start\` + - \`docusaurus build\` + - \`docusaurus deploy\`" `); }); it('prints detached flags as-is', () => { diff --git a/yarn.lock b/yarn.lock index 81a4ad899b..354aad8870 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9470,6 +9470,11 @@ jest-runtime@^28.1.1: slash "^3.0.0" strip-bom "^4.0.0" +jest-serializer-ansi-escapes@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/jest-serializer-ansi-escapes/-/jest-serializer-ansi-escapes-2.0.1.tgz#053fc7f2d8629ad127afb6a31e542b65c6ad7806" + integrity sha512-+BuVKZQutcejSuODTleG/CV+8OVONZSOSrtrQRG8isTLu367JVKK+/yaG2jGs5O6MPBZ88WNy5jg8hqhd/p6pw== + jest-serializer-react-helmet-async@^1.0.21: version "1.0.21" resolved "https://registry.yarnpkg.com/jest-serializer-react-helmet-async/-/jest-serializer-react-helmet-async-1.0.21.tgz#bf2aee7522909bc4c933a0911db236b92db4685c"