Skip to content

Commit e204454

Browse files
committed
chore(jest-message-util): replace chalk with picocolors
1 parent 95365f5 commit e204454

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

packages/jest-message-util/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
"@babel/code-frame": "^7.12.13",
2626
"@jest/types": "workspace:*",
2727
"@types/stack-utils": "^2.0.0",
28-
"chalk": "^4.0.0",
2928
"graceful-fs": "^4.2.9",
3029
"micromatch": "^4.0.7",
30+
"picocolors": "^1.0.1",
3131
"pretty-format": "workspace:*",
3232
"slash": "^3.0.0",
3333
"stack-utils": "^2.0.3"

packages/jest-message-util/src/index.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import * as path from 'path';
99
import {fileURLToPath} from 'url';
1010
import {types} from 'util';
1111
import {codeFrameColumns} from '@babel/code-frame';
12-
import chalk = require('chalk');
1312
import * as fs from 'graceful-fs';
1413
import micromatch = require('micromatch');
14+
import * as pico from 'picocolors';
1515
import slash = require('slash');
1616
import StackUtils = require('stack-utils');
1717
import type {Config, TestResult} from '@jest/types';
@@ -58,8 +58,8 @@ const TITLE_INDENT = ' ';
5858
const MESSAGE_INDENT = ' ';
5959
const STACK_INDENT = ' ';
6060
const ANCESTRY_SEPARATOR = ' \u203A ';
61-
const TITLE_BULLET = chalk.bold('\u25CF ');
62-
const STACK_TRACE_COLOR = chalk.dim;
61+
const TITLE_BULLET = pico.bold('\u25CF ');
62+
const STACK_TRACE_COLOR = pico.dim;
6363
const STACK_PATH_REGEXP = /\s*at.*\(?(:\d*:\d*|native)\)?/;
6464
const EXEC_ERROR_MESSAGE = 'Test suite failed to run';
6565
const NOT_EMPTY_LINE_REGEXP = /^(?!$)/gm;
@@ -111,10 +111,14 @@ function checkForCommonEnvironmentErrors(error: string) {
111111

112112
function warnAboutWrongTestEnvironment(error: string, env: 'jsdom' | 'node') {
113113
return (
114-
chalk.bold.red(
115-
`The error below may be caused by using the wrong test environment, see ${chalk.dim.underline(
116-
'https://jestjs.io/docs/configuration#testenvironment-string',
117-
)}.\nConsider using the "${env}" test environment.\n\n`,
114+
pico.bold(
115+
pico.red(
116+
`The error below may be caused by using the wrong test environment, see ${pico.dim(
117+
pico.underline(
118+
'https://jestjs.io/docs/configuration#testenvironment-string',
119+
),
120+
)}.\nConsider using the "${env}" test environment.\n\n`,
121+
),
118122
) + error
119123
);
120124
}
@@ -305,7 +309,7 @@ export const formatPath = (
305309
micromatch([filePath], config.testMatch).length > 0) ||
306310
filePath === relativeTestPath
307311
) {
308-
filePath = chalk.reset.cyan(filePath);
312+
filePath = pico.reset(pico.cyan(filePath));
309313
}
310314
return STACK_TRACE_COLOR(match[1]) + filePath + STACK_TRACE_COLOR(match[3]);
311315
};
@@ -488,12 +492,14 @@ export const formatResultsErrors = (
488492
content,
489493
);
490494

491-
const title = `${chalk.bold.red(
492-
TITLE_INDENT +
493-
TITLE_BULLET +
494-
result.ancestorTitles.join(ANCESTRY_SEPARATOR) +
495-
(result.ancestorTitles.length > 0 ? ANCESTRY_SEPARATOR : '') +
496-
result.title,
495+
const title = `${pico.bold(
496+
pico.red(
497+
TITLE_INDENT +
498+
TITLE_BULLET +
499+
result.ancestorTitles.join(ANCESTRY_SEPARATOR) +
500+
(result.ancestorTitles.length > 0 ? ANCESTRY_SEPARATOR : '') +
501+
result.title,
502+
),
497503
)}\n`;
498504

499505
return `${title}\n${formatErrorStack(

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13299,9 +13299,9 @@ __metadata:
1329913299
"@types/graceful-fs": ^4.1.3
1330013300
"@types/micromatch": ^4.0.7
1330113301
"@types/stack-utils": ^2.0.0
13302-
chalk: ^4.0.0
1330313302
graceful-fs: ^4.2.9
1330413303
micromatch: ^4.0.7
13304+
picocolors: ^1.0.1
1330513305
pretty-format: "workspace:*"
1330613306
slash: ^3.0.0
1330713307
stack-utils: ^2.0.3

0 commit comments

Comments
 (0)