cleanup(testing): migrate jest to picocolors (#29561)
migrates `@nx/jest` from `chalk` to `picocolors` Part of https://github.com/es-tooling/ecosystem-cleanup/issues/117 <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
f98ae78734
commit
b491489cb2
@ -4,13 +4,15 @@
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["**/*.ts"],
|
||||
"excludedFiles": ["./src/migrations/**"],
|
||||
"rules": {
|
||||
"no-restricted-imports": ["error", "@nx/workspace"]
|
||||
"no-restricted-imports": [
|
||||
"error",
|
||||
"@nx/workspace",
|
||||
{
|
||||
"name": "chalk",
|
||||
"message": "Please use `picocolors` in place of `chalk` for rendering terminal colors"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@ -40,12 +40,12 @@
|
||||
"@nx/devkit": "file:../devkit",
|
||||
"@nx/js": "file:../js",
|
||||
"@phenomnomnominal/tsquery": "~5.0.1",
|
||||
"chalk": "^4.1.0",
|
||||
"identity-obj-proxy": "3.0.0",
|
||||
"jest-config": "^29.4.1",
|
||||
"jest-resolve": "^29.4.1",
|
||||
"jest-util": "^29.4.1",
|
||||
"minimatch": "9.0.3",
|
||||
"picocolors": "^1.1.0",
|
||||
"resolve.exports": "2.0.3",
|
||||
"semver": "^7.5.3",
|
||||
"tslib": "^2.3.0",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { AggregatedResult } from '@jest/reporters';
|
||||
import { pluralize, formatTime } from 'jest-util';
|
||||
import * as chalk from 'chalk';
|
||||
import * as pc from 'picocolors';
|
||||
|
||||
/**
|
||||
* Copied from the jest repo because these utility functions are not exposed through the package
|
||||
@ -50,9 +50,9 @@ const renderTime = (runTime: number, estimatedTime: number, width: number) => {
|
||||
// If we are more than one second over the estimated time, highlight it.
|
||||
const renderedTime =
|
||||
estimatedTime && runTime >= estimatedTime + 1
|
||||
? chalk.bold.yellow(formatTime(runTime, 0))
|
||||
? pc.bold(pc.yellow(formatTime(runTime, 0)))
|
||||
: formatTime(runTime, 0);
|
||||
let time = chalk.bold(`Time:`) + ` ${renderedTime}`;
|
||||
let time = pc.bold(`Time:`) + ` ${renderedTime}`;
|
||||
if (runTime < estimatedTime) {
|
||||
time += `, estimated ${formatTime(estimatedTime, 0)}`;
|
||||
}
|
||||
@ -68,8 +68,8 @@ const renderTime = (runTime: number, estimatedTime: number, width: number) => {
|
||||
if (availableWidth >= 2) {
|
||||
time +=
|
||||
'\n' +
|
||||
chalk.green('█').repeat(length) +
|
||||
chalk.white('█').repeat(availableWidth - length);
|
||||
pc.green('█').repeat(length) +
|
||||
pc.white('█').repeat(availableWidth - length);
|
||||
}
|
||||
}
|
||||
return time;
|
||||
@ -120,12 +120,12 @@ export const getSummary = (
|
||||
const width = options?.width || 0;
|
||||
|
||||
const suites =
|
||||
chalk.bold('Test Suites: ') +
|
||||
(suitesFailed ? chalk.bold.red(`${suitesFailed} failed`) + ', ' : '') +
|
||||
pc.bold('Test Suites: ') +
|
||||
(suitesFailed ? pc.bold(pc.red(`${suitesFailed} failed`)) + ', ' : '') +
|
||||
(suitesPending
|
||||
? chalk.bold.yellow(`${suitesPending} skipped`) + ', '
|
||||
? pc.bold(pc.yellow(`${suitesPending} skipped`)) + ', '
|
||||
: '') +
|
||||
(suitesPassed ? chalk.bold.green(`${suitesPassed} passed`) + ', ' : '') +
|
||||
(suitesPassed ? pc.bold(pc.green(`${suitesPassed} passed`)) + ', ' : '') +
|
||||
(suitesRun !== suitesTotal
|
||||
? suitesRun + ' of ' + suitesTotal
|
||||
: suitesTotal) +
|
||||
@ -138,50 +138,50 @@ export const getSummary = (
|
||||
const updatedTestsTotal = testsTotal + numTotalTests;
|
||||
|
||||
const tests =
|
||||
chalk.bold('Tests: ') +
|
||||
pc.bold('Tests: ') +
|
||||
(updatedTestsFailed > 0
|
||||
? chalk.bold.red(`${updatedTestsFailed} failed`) + ', '
|
||||
? pc.bold(pc.red(`${updatedTestsFailed} failed`)) + ', '
|
||||
: '') +
|
||||
(updatedTestsPending > 0
|
||||
? chalk.bold.yellow(`${updatedTestsPending} skipped`) + ', '
|
||||
? pc.bold(pc.yellow(`${updatedTestsPending} skipped`)) + ', '
|
||||
: '') +
|
||||
(updatedTestsTodo > 0
|
||||
? chalk.bold.magenta(`${updatedTestsTodo} todo`) + ', '
|
||||
? pc.bold(pc.magenta(`${updatedTestsTodo} todo`)) + ', '
|
||||
: '') +
|
||||
(updatedTestsPassed > 0
|
||||
? chalk.bold.green(`${updatedTestsPassed} passed`) + ', '
|
||||
? pc.bold(pc.green(`${updatedTestsPassed} passed`)) + ', '
|
||||
: '') +
|
||||
`${updatedTestsTotal} total`;
|
||||
|
||||
const snapshots =
|
||||
chalk.bold('Snapshots: ') +
|
||||
pc.bold('Snapshots: ') +
|
||||
(snapshotsFailed
|
||||
? chalk.bold.red(`${snapshotsFailed} failed`) + ', '
|
||||
? pc.bold(pc.red(`${snapshotsFailed} failed`)) + ', '
|
||||
: '') +
|
||||
(snapshotsOutdated && !snapshotsDidUpdate
|
||||
? chalk.bold.yellow(`${snapshotsOutdated} obsolete`) + ', '
|
||||
? pc.bold(pc.yellow(`${snapshotsOutdated} obsolete`)) + ', '
|
||||
: '') +
|
||||
(snapshotsOutdated && snapshotsDidUpdate
|
||||
? chalk.bold.green(`${snapshotsOutdated} removed`) + ', '
|
||||
? pc.bold(pc.green(`${snapshotsOutdated} removed`)) + ', '
|
||||
: '') +
|
||||
(snapshotsFilesRemoved && !snapshotsDidUpdate
|
||||
? chalk.bold.yellow(
|
||||
pluralize('file', snapshotsFilesRemoved) + ' obsolete'
|
||||
? pc.bold(
|
||||
pc.yellow(pluralize('file', snapshotsFilesRemoved) + ' obsolete')
|
||||
) + ', '
|
||||
: '') +
|
||||
(snapshotsFilesRemoved && snapshotsDidUpdate
|
||||
? chalk.bold.green(
|
||||
pluralize('file', snapshotsFilesRemoved) + ' removed'
|
||||
? pc.bold(
|
||||
pc.green(pluralize('file', snapshotsFilesRemoved) + ' removed')
|
||||
) + ', '
|
||||
: '') +
|
||||
(snapshotsUpdated
|
||||
? chalk.bold.green(`${snapshotsUpdated} updated`) + ', '
|
||||
? pc.bold(pc.green(`${snapshotsUpdated} updated`)) + ', '
|
||||
: '') +
|
||||
(snapshotsAdded
|
||||
? chalk.bold.green(`${snapshotsAdded} written`) + ', '
|
||||
? pc.bold(pc.green(`${snapshotsAdded} written`)) + ', '
|
||||
: '') +
|
||||
(snapshotsPassed
|
||||
? chalk.bold.green(`${snapshotsPassed} passed`) + ', '
|
||||
? pc.bold(pc.green(`${snapshotsPassed} passed`)) + ', '
|
||||
: '') +
|
||||
`${snapshotsTotal} total`;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user