diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ca0115e5011..3124396e64b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Chore & Maintenance +- `[@jest/core]` Use `pluralize` from `jest-util` rather than own internal ([#14322](https://github.com/jestjs/jest/pull/14322)) + ### Performance ## 29.6.1 diff --git a/packages/jest-core/src/cli/index.ts b/packages/jest-core/src/cli/index.ts index 40c9f4c39c9a..20236a5c2d35 100644 --- a/packages/jest-core/src/cli/index.ts +++ b/packages/jest-core/src/cli/index.ts @@ -16,7 +16,7 @@ import type {ChangedFilesPromise} from 'jest-changed-files'; import {readConfigs} from 'jest-config'; import type {IHasteMap} from 'jest-haste-map'; import Runtime from 'jest-runtime'; -import {createDirectory, preRunMessage} from 'jest-util'; +import {createDirectory, pluralize, preRunMessage} from 'jest-util'; import {TestWatcher} from 'jest-watcher'; import {formatHandleErrors} from '../collectHandles'; import getChangedFilesPromise from '../getChangedFilesPromise'; @@ -26,7 +26,6 @@ import getSelectProjectsMessage from '../getSelectProjectsMessage'; import createContext from '../lib/createContext'; import handleDeprecationWarnings from '../lib/handleDeprecationWarnings'; import logDebugMessages from '../lib/logDebugMessages'; -import pluralize from '../pluralize'; import runJest from '../runJest'; import type {Filter} from '../types'; import watch from '../watch'; diff --git a/packages/jest-core/src/getNoTestFound.ts b/packages/jest-core/src/getNoTestFound.ts index 3ccef939e006..931de697aa24 100644 --- a/packages/jest-core/src/getNoTestFound.ts +++ b/packages/jest-core/src/getNoTestFound.ts @@ -7,7 +7,7 @@ import chalk = require('chalk'); import type {Config} from '@jest/types'; -import pluralize from './pluralize'; +import {pluralize} from 'jest-util'; import type {TestRunData} from './types'; export default function getNoTestFound( diff --git a/packages/jest-core/src/getNoTestFoundVerbose.ts b/packages/jest-core/src/getNoTestFoundVerbose.ts index d7d3f71a84f2..0f9ef7f1de00 100644 --- a/packages/jest-core/src/getNoTestFoundVerbose.ts +++ b/packages/jest-core/src/getNoTestFoundVerbose.ts @@ -7,7 +7,7 @@ import chalk = require('chalk'); import type {Config} from '@jest/types'; -import pluralize from './pluralize'; +import {pluralize} from 'jest-util'; import type {Stats, TestRunData} from './types'; export default function getNoTestFoundVerbose( diff --git a/packages/jest-core/src/pluralize.ts b/packages/jest-core/src/pluralize.ts deleted file mode 100644 index c9b0413ddd91..000000000000 --- a/packages/jest-core/src/pluralize.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -export default function pluralize( - word: string, - count: number, - ending: string, -): string { - return `${count} ${word}${count === 1 ? '' : ending}`; -} diff --git a/packages/jest-util/src/pluralize.ts b/packages/jest-util/src/pluralize.ts index 42c1242a7796..cc622b74b0e0 100644 --- a/packages/jest-util/src/pluralize.ts +++ b/packages/jest-util/src/pluralize.ts @@ -5,6 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -export default function pluralize(word: string, count: number): string { - return `${count} ${word}${count === 1 ? '' : 's'}`; +export default function pluralize( + word: string, + count: number, + ending = 's', +): string { + return `${count} ${word}${count === 1 ? '' : ending}`; }