From 305606f12d1c00b335df6f6584cba79b6ffe159e Mon Sep 17 00:00:00 2001 From: Adam Skoufis Date: Wed, 17 Jul 2024 16:30:38 +1000 Subject: [PATCH 1/2] feat: Show `rootDir` in error message when a `preset` fails to load --- .../src/__tests__/__snapshots__/normalize.test.ts.snap | 2 +- packages/jest-config/src/normalize.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jest-config/src/__tests__/__snapshots__/normalize.test.ts.snap b/packages/jest-config/src/__tests__/__snapshots__/normalize.test.ts.snap index 990000454eeb..514648c12674 100644 --- a/packages/jest-config/src/__tests__/__snapshots__/normalize.test.ts.snap +++ b/packages/jest-config/src/__tests__/__snapshots__/normalize.test.ts.snap @@ -367,7 +367,7 @@ exports[`preset throws when module was found but no "jest-preset.js" or "jest-pr exports[`preset throws when preset not found 1`] = ` "Validation Error: - Preset doesnt-exist not found. + Preset doesnt-exist not found relative to rootDir /root/path/foo. Configuration Documentation: https://jestjs.io/docs/configuration diff --git a/packages/jest-config/src/normalize.ts b/packages/jest-config/src/normalize.ts index e8b3cc9d726a..a0724cc09754 100644 --- a/packages/jest-config/src/normalize.ts +++ b/packages/jest-config/src/normalize.ts @@ -169,7 +169,7 @@ const setupPreset = async ( ); } throw createConfigError( - ` Preset ${chalk.bold(presetPath)} not found.`, + ` Preset ${chalk.bold(presetPath)} not found relative to rootDir ${chalk.bold(options.rootDir)}.`, ); } throw createConfigError( From ef24297e551fc6b3643ee2ad86742863df06fe6e Mon Sep 17 00:00:00 2001 From: Adam Skoufis Date: Wed, 17 Jul 2024 16:35:52 +1000 Subject: [PATCH 2/2] Update `CHANGELOG.md` --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01e5bb097cc7..e121168ff8ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - `[jest-config]` Loads config file from provided path in `package.json` ([#14044](https://github.com/facebook/jest/pull/14044)) - `[jest-config]` Allow loading `jest.config.cts` files ([#14070](https://github.com/facebook/jest/pull/14070)) - `[jest-config]` Added an option to disable `ts-node` typechecking ([#15161](https://github.com/jestjs/jest/pull/15161)) +- `[jest-config]` Show `rootDir` in error message when a `preset` fails to load ([#15194](https://github.com/jestjs/jest/pull/15194)) - `[@jest/core]` Group together open handles with the same stack trace ([#13417](https://github.com/jestjs/jest/pull/13417), & [#14789](https://github.com/jestjs/jest/pull/14789)) - `[@jest/core]` Add `perfStats` to surface test setup overhead ([#14622](https://github.com/jestjs/jest/pull/14622)) - `[@jest/core]` [**BREAKING**] Changed `--filter` to accept an object with shape `{ filtered: Array }` to match [documentation](https://jestjs.io/docs/cli#--filterfile) ([#13319](https://github.com/jestjs/jest/pull/13319))