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:
Tom Mrazauskas 2022-06-27 10:03:51 +03:00 committed by GitHub
parent 7720a1cfd8
commit bb558ffcb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 11 deletions

View file

@ -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(
`"<cyan><underline>"keepAnsi"</underline></color>"`,
);
});
it('url', () => {
expect(logger.url('https://docusaurus.io/keepAnsi')).toMatchInlineSnapshot(
`"https://docusaurus.io/keepAnsi"`,
`"<cyan><underline>https://docusaurus.io/keepAnsi</underline></color>"`,
);
});
it('id', () => {
expect(logger.name('keepAnsi')).toMatchInlineSnapshot(`"keepAnsi"`);
expect(logger.name('keepAnsi')).toMatchInlineSnapshot(
`"<blue><bold>keepAnsi</intensity></color>"`,
);
});
it('code', () => {
expect(logger.code('keepAnsi')).toMatchInlineSnapshot(`"\`keepAnsi\`"`);
expect(logger.code('keepAnsi')).toMatchInlineSnapshot(
`"<cyan>\`keepAnsi\`</color>"`,
);
});
it('subdue', () => {
expect(logger.subdue('keepAnsi')).toMatchInlineSnapshot(`"keepAnsi"`);
expect(logger.subdue('keepAnsi')).toMatchInlineSnapshot(
`"<gray>keepAnsi</color>"`,
);
});
});
@ -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 <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', () => {
@ -59,9 +65,9 @@ describe('interpolate', () => {
]}`,
).toMatchInlineSnapshot(`
"(keepAnsi) The following commands are available:
- \`docusaurus start\`
- \`docusaurus build\`
- \`docusaurus deploy\`"
- <cyan>\`docusaurus start\`</color>
- <cyan>\`docusaurus build\`</color>
- <cyan>\`docusaurus deploy\`</color>"
`);
});
it('prints detached flags as-is', () => {