diff --git a/CHANGELOG.md b/CHANGELOG.md index 917db93ebb8c..4111f178bfe3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - `[jest-runtime]` Fix issue where user cannot utilize dynamic import despite specifying `--experimental-vm-modules` Node option ([#15842](https://github.com/jestjs/jest/pull/15842)) +### Chore & Maintenance + +- `[docs]` Update V30 migration guide to notify users on `jest.mock()` work with case-sensitive path ([#15849](https://github.com/jestjs/jest/pull/15849)) + ## 30.2.0 ### Chore & Maintenance diff --git a/docs/UpgradingToJest30.md b/docs/UpgradingToJest30.md index f51c7488e863..ba6dddf58650 100644 --- a/docs/UpgradingToJest30.md +++ b/docs/UpgradingToJest30.md @@ -184,6 +184,22 @@ Some TypeScript types related to mock functions have been removed from the publi If you were using `jest.SpyInstance` (for instance, to annotate the return of `jest.spyOn`), you should update to using [`jest.Spied`](./MockFunctionAPI.md#jestspiedsource). +### `jest.mock` only works with case-sensitive module path + +`jest.mock()` will only work case-sensitive module path from now on. At best, this is an edge case since most users would follow OS filename pattern behavior. We recommend to use correctly named module path to avoid similar breakages in the future. + +Old code (Jest 29): + +```js +jest.mock('./path/to/FILENAME.js'); // This works EVEN when you only have `filename.js` +``` + +New code (Jest 30): + +```js +jest.mock('./path/to/filename.js'); // This strictly works when you ONLY have `filename.js` +``` + ## Module & Runtime Changes ### ESM Module Support and Internal Restructuring diff --git a/website/versioned_docs/version-30.0/UpgradingToJest30.md b/website/versioned_docs/version-30.0/UpgradingToJest30.md index f51c7488e863..ba6dddf58650 100644 --- a/website/versioned_docs/version-30.0/UpgradingToJest30.md +++ b/website/versioned_docs/version-30.0/UpgradingToJest30.md @@ -184,6 +184,22 @@ Some TypeScript types related to mock functions have been removed from the publi If you were using `jest.SpyInstance` (for instance, to annotate the return of `jest.spyOn`), you should update to using [`jest.Spied`](./MockFunctionAPI.md#jestspiedsource). +### `jest.mock` only works with case-sensitive module path + +`jest.mock()` will only work case-sensitive module path from now on. At best, this is an edge case since most users would follow OS filename pattern behavior. We recommend to use correctly named module path to avoid similar breakages in the future. + +Old code (Jest 29): + +```js +jest.mock('./path/to/FILENAME.js'); // This works EVEN when you only have `filename.js` +``` + +New code (Jest 30): + +```js +jest.mock('./path/to/filename.js'); // This strictly works when you ONLY have `filename.js` +``` + ## Module & Runtime Changes ### ESM Module Support and Internal Restructuring