Skip to content

Commit cb49b2e

Browse files
authored
doc: update v30 migration guide for jest.mock() strictly case-sentitive path (#15849)
1 parent 486ae3d commit cb49b2e

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
- `[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))
1010

11+
### Chore & Maintenance
12+
13+
- `[docs]` Update V30 migration guide to notify users on `jest.mock()` work with case-sensitive path ([#15849](https://github.com/jestjs/jest/pull/15849))
14+
1115
## 30.2.0
1216

1317
### Chore & Maintenance

docs/UpgradingToJest30.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,22 @@ Some TypeScript types related to mock functions have been removed from the publi
184184

185185
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).
186186

187+
### `jest.mock` only works with case-sensitive module path
188+
189+
`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.
190+
191+
Old code (Jest 29):
192+
193+
```js
194+
jest.mock('./path/to/FILENAME.js'); // This works EVEN when you only have `filename.js`
195+
```
196+
197+
New code (Jest 30):
198+
199+
```js
200+
jest.mock('./path/to/filename.js'); // This strictly works when you ONLY have `filename.js`
201+
```
202+
187203
## Module & Runtime Changes
188204

189205
### ESM Module Support and Internal Restructuring

website/versioned_docs/version-30.0/UpgradingToJest30.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,22 @@ Some TypeScript types related to mock functions have been removed from the publi
184184

185185
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).
186186

187+
### `jest.mock` only works with case-sensitive module path
188+
189+
`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.
190+
191+
Old code (Jest 29):
192+
193+
```js
194+
jest.mock('./path/to/FILENAME.js'); // This works EVEN when you only have `filename.js`
195+
```
196+
197+
New code (Jest 30):
198+
199+
```js
200+
jest.mock('./path/to/filename.js'); // This strictly works when you ONLY have `filename.js`
201+
```
202+
187203
## Module & Runtime Changes
188204

189205
### ESM Module Support and Internal Restructuring

0 commit comments

Comments
 (0)