mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-29 17:07:08 +02:00
test(logger): use jest-serializer-ansi-escapes
(#7685)
* chore(logger): use jest-serializer-ansi-escapes * move serialiser to jest.config
This commit is contained in:
parent
7720a1cfd8
commit
bb558ffcb9
4 changed files with 24 additions and 11 deletions
1
jest.config.mjs
vendored
1
jest.config.mjs
vendored
|
@ -80,6 +80,7 @@ export default {
|
||||||
},
|
},
|
||||||
snapshotSerializers: [
|
snapshotSerializers: [
|
||||||
'<rootDir>/jest/snapshotPathNormalizer.ts',
|
'<rootDir>/jest/snapshotPathNormalizer.ts',
|
||||||
|
'jest-serializer-ansi-escapes',
|
||||||
'jest-serializer-react-helmet-async',
|
'jest-serializer-react-helmet-async',
|
||||||
],
|
],
|
||||||
snapshotFormat: {
|
snapshotFormat: {
|
||||||
|
|
|
@ -94,6 +94,7 @@
|
||||||
"image-size": "^1.0.1",
|
"image-size": "^1.0.1",
|
||||||
"jest": "^28.1.1",
|
"jest": "^28.1.1",
|
||||||
"jest-environment-jsdom": "^28.1.1",
|
"jest-environment-jsdom": "^28.1.1",
|
||||||
|
"jest-serializer-ansi-escapes": "^2.0.1",
|
||||||
"jest-serializer-react-helmet-async": "^1.0.21",
|
"jest-serializer-react-helmet-async": "^1.0.21",
|
||||||
"lerna": "^5.1.4",
|
"lerna": "^5.1.4",
|
||||||
"lerna-changelog": "^2.2.0",
|
"lerna-changelog": "^2.2.0",
|
||||||
|
|
|
@ -8,25 +8,31 @@
|
||||||
import {jest} from '@jest/globals';
|
import {jest} from '@jest/globals';
|
||||||
import logger from '../index';
|
import logger from '../index';
|
||||||
|
|
||||||
// cSpell:ignore mkeep
|
|
||||||
|
|
||||||
describe('formatters', () => {
|
describe('formatters', () => {
|
||||||
it('path', () => {
|
it('path', () => {
|
||||||
expect(logger.path('keepAnsi')).toMatchInlineSnapshot(`"[36m[4m"keepAnsi"[24m[39m"`);
|
expect(logger.path('keepAnsi')).toMatchInlineSnapshot(
|
||||||
|
`"<cyan><underline>"keepAnsi"</underline></color>"`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
it('url', () => {
|
it('url', () => {
|
||||||
expect(logger.url('https://docusaurus.io/keepAnsi')).toMatchInlineSnapshot(
|
expect(logger.url('https://docusaurus.io/keepAnsi')).toMatchInlineSnapshot(
|
||||||
`"[36m[4mhttps://docusaurus.io/keepAnsi[24m[39m"`,
|
`"<cyan><underline>https://docusaurus.io/keepAnsi</underline></color>"`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('id', () => {
|
it('id', () => {
|
||||||
expect(logger.name('keepAnsi')).toMatchInlineSnapshot(`"[34m[1mkeepAnsi[22m[39m"`);
|
expect(logger.name('keepAnsi')).toMatchInlineSnapshot(
|
||||||
|
`"<blue><bold>keepAnsi</intensity></color>"`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
it('code', () => {
|
it('code', () => {
|
||||||
expect(logger.code('keepAnsi')).toMatchInlineSnapshot(`"[36m\`keepAnsi\`[39m"`);
|
expect(logger.code('keepAnsi')).toMatchInlineSnapshot(
|
||||||
|
`"<cyan>\`keepAnsi\`</color>"`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
it('subdue', () => {
|
it('subdue', () => {
|
||||||
expect(logger.subdue('keepAnsi')).toMatchInlineSnapshot(`"[90mkeepAnsi[39m"`);
|
expect(logger.subdue('keepAnsi')).toMatchInlineSnapshot(
|
||||||
|
`"<gray>keepAnsi</color>"`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -47,7 +53,7 @@ describe('interpolate', () => {
|
||||||
expect(
|
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')"}`,
|
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(
|
).toMatchInlineSnapshot(
|
||||||
`"(keepAnsi) The package at [36m[4m"packages/docusaurus"[24m[39m has [33m10[39m files. [34m[1mBabel[22m[39m is exported here [90m(as a preset)[39m that you can with [36m\`require.resolve('@docusaurus/core/lib/babel/preset')\`[39m"`,
|
`"(keepAnsi) The package at <cyan><underline>"packages/docusaurus"</underline></color> has <yellow>10</color> files. <blue><bold>Babel</intensity></color> is exported here <gray>(as a preset)</color> that you can with <cyan>\`require.resolve('@docusaurus/core/lib/babel/preset')\`</color>"`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('interpolates arrays with flags', () => {
|
it('interpolates arrays with flags', () => {
|
||||||
|
@ -59,9 +65,9 @@ describe('interpolate', () => {
|
||||||
]}`,
|
]}`,
|
||||||
).toMatchInlineSnapshot(`
|
).toMatchInlineSnapshot(`
|
||||||
"(keepAnsi) The following commands are available:
|
"(keepAnsi) The following commands are available:
|
||||||
- [36m\`docusaurus start\`[39m
|
- <cyan>\`docusaurus start\`</color>
|
||||||
- [36m\`docusaurus build\`[39m
|
- <cyan>\`docusaurus build\`</color>
|
||||||
- [36m\`docusaurus deploy\`[39m"
|
- <cyan>\`docusaurus deploy\`</color>"
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
it('prints detached flags as-is', () => {
|
it('prints detached flags as-is', () => {
|
||||||
|
|
|
@ -9470,6 +9470,11 @@ jest-runtime@^28.1.1:
|
||||||
slash "^3.0.0"
|
slash "^3.0.0"
|
||||||
strip-bom "^4.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:
|
jest-serializer-react-helmet-async@^1.0.21:
|
||||||
version "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"
|
resolved "https://registry.yarnpkg.com/jest-serializer-react-helmet-async/-/jest-serializer-react-helmet-async-1.0.21.tgz#bf2aee7522909bc4c933a0911db236b92db4685c"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue