You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`[jest-config]` Make sure to respect `runInBand` option ([#14578](https://github.com/facebook/jest/pull/14578))
27
27
-`[@jest/expect-utils]` Fix comparison of `DataView` ([#14408](https://github.com/jestjs/jest/pull/14408))
28
+
-`[@jest/expect-utils]`[**BREAKING**] exclude non-enumerable in object matching ([#14670](https://github.com/jestjs/jest/pull/14670))
28
29
-`[jest-leak-detector]` Make leak-detector more aggressive when running GC ([#14526](https://github.com/jestjs/jest/pull/14526))
29
30
-`[jest-runtime]` Properly handle re-exported native modules in ESM via CJS ([#14589](https://github.com/jestjs/jest/pull/14589))
30
31
-`[jest-util]` Make sure `isInteractive` works in a browser ([#14552](https://github.com/jestjs/jest/pull/14552))
@@ -36,15 +37,22 @@
36
37
37
38
### Performance
38
39
39
-
-`[*]`[**BREAKING**] Bundle all of Jest's modules into `index.js` ([#12348](https://github.com/jestjs/jest/pull/12348) & [#14550](https://github.com/jestjs/jest/pull/14550))
40
+
-`[*]`[**BREAKING**] Bundle all of Jest's modules into `index.js` ([#12348](https://github.com/jestjs/jest/pull/12348), [#14550](https://github.com/jestjs/jest/pull/14550) & [#14661](https://github.com/jestjs/jest/pull/14661))
40
41
41
42
### Chore & Maintenance
42
43
43
44
-`[*]`[**BREAKING**] Drop support for Node.js versions 14 and 19 ([#14460](https://github.com/jestjs/jest/pull/14460))
44
45
-`[*]`[**BREAKING**] Drop support for `[email protected]`, minimum version is now `5.0` ([#14542](https://github.com/facebook/jest/pull/14542))
45
46
-`[*]` Depend on exact versions of monorepo dependencies instead of `^` range ([#14553](https://github.com/facebook/jest/pull/14553))
47
+
-`[*]`[**BREAKING**] Add ESM wrapper for all of Jest's modules ([#14661](https://github.com/jestjs/jest/pull/14661))
48
+
-`[docs]` Fix typos in `CHANGELOG.md` and `packages/jest-validate/README.md` ([#14640](https://github.com/jestjs/jest/pull/14640))
49
+
-`[docs]` Don't use alias matchers in docs ([#14631](https://github.com/facebook/jest/pull/14631))
46
50
-`[babel-jest, babel-preset-jest]`[**BREAKING**] Increase peer dependency of `@babel/core` to `^7.11` ([#14109](https://github.com/jestjs/jest/pull/14109))
-`[*]` Use `sha256` instead of `md5` as hashing algortihm for compatibility with FIPS systems ([#12722](https://github.com/facebook/jest/pull/12722))
645
+
-`[*]` Use `sha256` instead of `md5` as hashing algorithm for compatibility with FIPS systems ([#12722](https://github.com/facebook/jest/pull/12722))
638
646
-`[babel-jest]`[**BREAKING**] Pass `rootDir` as `root` in Babel's options ([#12689](https://github.com/facebook/jest/pull/12689))
639
647
-`[expect]` Move typings of `.not`, `.rejects` and `.resolves` modifiers outside of `Matchers` interface ([#12346](https://github.com/facebook/jest/pull/12346))
640
648
-`[expect]` Throw useful error if `expect.extend` is called with invalid matchers ([#12488](https://github.com/facebook/jest/pull/12488))
@@ -1441,7 +1449,7 @@
1441
1449
-`[*]` Upgrade to chalk@4 ([#9752](https://github.com/facebook/jest/pull/9752))
1442
1450
-`[*]` Remove usage of `realpath-native` ([#9952](https://github.com/facebook/jest/pull/9952))
1443
1451
-`[docs]` Fix example reference implementation to use Jest with Phabricator ([#8662](https://github.com/facebook/jest/pull/8662))
1444
-
-`[docs]` Added default compiler to tranform ([#8583](https://github.com/facebook/jest/pull/8583))
1452
+
-`[docs]` Added default compiler to transform ([#8583](https://github.com/facebook/jest/pull/8583))
1445
1453
-`[docs]` Updated Testing Frameworks guide with React; make it generic ([#9106](https://github.com/facebook/jest/pull/9106))
1446
1454
-`[expect, jest-mock, pretty-format]`[**BREAKING**] Remove `build-es5` from package ([#9945](https://github.com/facebook/jest/pull/9945))
1447
1455
-`[@jest/fake-timers, @jest/environment]`[**BREAKING**] Rename `LolexFakeTimers` to `ModernFakeTimers` ([#9960](https://github.com/facebook/jest/pull/9960))
@@ -3481,7 +3489,7 @@ See <https://jestjs.io/blog/2016/12/15/2016-in-jest>
3481
3489
- Added `--watchAll`, made `--watch` interactive and added the ability to update snapshots and select test patterns in watch mode.
3482
3490
- Jest uses verbose mode when running a single test file.
3483
3491
- Console messages are now buffered and printed along with the test results.
3484
-
- Fix `testEnvironment` resolution to prefer `jest-environment-{name}` instead of `{name}` only. This prevents a module colision when using `jsdom` as test environment.
3492
+
- Fix `testEnvironment` resolution to prefer `jest-environment-{name}` instead of `{name}` only. This prevents a module collision when using `jsdom` as test environment.
3485
3493
-`moduleNameMapper` now uses a resolution algorithm.
3486
3494
- Improved performance for small test runs.
3487
3495
- Improved API documentation.
@@ -3620,7 +3628,7 @@ See <https://jestjs.io/blog/2016/12/15/2016-in-jest>
3620
3628
- Clear the terminal window when using `--watch`.
3621
3629
- By default, `--watch` will now only runs tests related to changed files. `--watch=all` can be used to run all tests on file system changes.
3622
3630
- Debounce `--watch` re-runs to not trigger test runs during a branch switch in version control.
3623
-
- Added `jest.fn()` and `jest.fn(implementation)` as convenient shorcuts for `jest.genMockFunction()` and `jest.genMockFunction().mockImplementation()`.
3631
+
- Added `jest.fn()` and `jest.fn(implementation)` as convenient shortcuts for `jest.genMockFunction()` and `jest.genMockFunction().mockImplementation()`.
3624
3632
- Added an `automock` option to turn off automocking globally.
3625
3633
- Added a "no tests found" message if no tests can be found.
3626
3634
- Jest sets `process.NODE_ENV` to `test` unless otherwise specified.
Copy file name to clipboardExpand all lines: docs/ExpectAPI.md
+4-26Lines changed: 4 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -144,8 +144,6 @@ Although the `.toBe` matcher **checks** referential identity, it **reports** a d
144
144
145
145
### `.toHaveBeenCalled()`
146
146
147
-
Also under the alias: `.toBeCalled()`
148
-
149
147
Use `.toHaveBeenCalledWith` to ensure that a mock function was called with specific arguments. The arguments are checked with the same algorithm that `.toEqual` uses.
150
148
151
149
For example, let's say you have a `drinkAll(drink, flavour)` function that takes a `drink` function and applies it to all available beverages. You might want to check that `drink` gets called for `'lemon'`, but not for `'octopus'`, because `'octopus'` flavour is really weird and why would anything be octopus-flavoured? You can do that with this test suite:
@@ -174,8 +172,6 @@ describe('drinkAll', () => {
174
172
175
173
### `.toHaveBeenCalledTimes(number)`
176
174
177
-
Also under the alias: `.toBeCalledTimes(number)`
178
-
179
175
Use `.toHaveBeenCalledTimes` to ensure that a mock function got called exact number of times.
180
176
181
177
For example, let's say you have a `drinkEach(drink, Array<flavor>)` function that takes a `drink` function and applies it to array of passed beverages. You might want to check that drink function was called exact number of times. You can do that with this test suite:
Use `.toHaveBeenCalledWith` to ensure that a mock function was called with specific arguments. The arguments are checked with the same algorithm that `.toEqual` uses.
196
190
197
191
For example, let's say that you can register a beverage with a `register` function, and `applyToAll(f)` should apply the function `f` to all registered beverages. To make sure this works, you could write:
@@ -208,8 +202,6 @@ test('registration applies correctly to orange La Croix', () => {
208
202
209
203
### `.toHaveBeenLastCalledWith(arg1, arg2, ...)`
210
204
211
-
Also under the alias: `.lastCalledWith(arg1, arg2, ...)`
212
-
213
205
If you have a mock function, you can use `.toHaveBeenLastCalledWith` to test what arguments it was last called with. For example, let's say you have a `applyToAllFlavors(f)` function that applies `f` to a bunch of flavors, and you want to ensure that when you call it, the last flavor it operates on is `'mango'`. You can write:
214
206
215
207
```js
@@ -222,8 +214,6 @@ test('applying to all flavors does mango last', () => {
Also under the alias: `.nthCalledWith(nthCall, arg1, arg2, ...)`
226
-
227
217
If you have a mock function, you can use `.toHaveBeenNthCalledWith` to test what arguments it was nth called with. For example, let's say you have a `drinkEach(drink, Array<flavor>)` function that applies `f` to a bunch of flavors, and you want to ensure that when you call it, the first flavor it operates on is `'lemon'` and the second one is `'octopus'`. You can write:
228
218
229
219
```js
@@ -243,8 +233,6 @@ The nth argument must be positive integer starting from 1.
243
233
244
234
### `.toHaveReturned()`
245
235
246
-
Also under the alias: `.toReturn()`
247
-
248
236
If you have a mock function, you can use `.toHaveReturned` to test that the mock function successfully returned (i.e., did not throw an error) at least one time. For example, let's say you have a mock `drink` that returns `true`. You can write:
Use `.toHaveReturnedTimes` to ensure that a mock function returned successfully (i.e., did not throw an error) an exact number of times. Any calls to the mock function that throw an error are not counted toward the number of times the function returned.
265
251
266
252
For example, let's say you have a mock `drink` that returns `true`. You can write:
Use `.toHaveLastReturnedWith` to test the specific value that a mock function last returned. If the last call to the mock function threw an error, then this matcher will fail no matter what value you provided as the expected return value.
303
285
304
286
For example, let's say you have a mock `drink` that returns the name of the beverage that was consumed. You can write:
Also under the alias: `.nthReturnedWith(nthCall, value)`
322
-
323
303
Use `.toHaveNthReturnedWith` to test the specific value that a mock function returned for the nth call. If the nth call to the mock function threw an error, then this matcher will fail no matter what value you provided as the expected return value.
324
304
325
305
For example, let's say you have a mock `drink` that returns the name of the beverage that was consumed. You can write:
@@ -782,8 +762,6 @@ describe('the La Croix cans on my desk', () => {
782
762
783
763
### `.toThrow(error?)`
784
764
785
-
Also under the alias: `.toThrowError(error?)`
786
-
787
765
Use `.toThrow` to test that a function throws when it is called. For example, if we want to test that `drinkFlavor('octopus')` throws, because octopus flavor is too disgusting to drink, we could write:
788
766
789
767
```js
@@ -888,7 +866,7 @@ Check out the section on [Inline Snapshots](SnapshotTesting.md#inline-snapshots)
888
866
889
867
### `expect.anything()`
890
868
891
-
`expect.anything()` matches anything but `null` or `undefined`. You can use it inside `toEqual` or `toBeCalledWith` instead of a literal value. For example, if you want to check that a mock function is called with a non-null argument:
869
+
`expect.anything()` matches anything but `null` or `undefined`. You can use it inside `toEqual` or `toHaveBeenCalledWith` instead of a literal value. For example, if you want to check that a mock function is called with a non-null argument:
892
870
893
871
```js
894
872
test('map calls its argument with a non-null argument', () => {
@@ -900,7 +878,7 @@ test('map calls its argument with a non-null argument', () => {
900
878
901
879
### `expect.any(constructor)`
902
880
903
-
`expect.any(constructor)` matches anything that was created with the given constructor or if it's a primitive that is of the passed type. You can use it inside `toEqual` or `toBeCalledWith` instead of a literal value. For example, if you want to check that a mock function is called with a number:
881
+
`expect.any(constructor)` matches anything that was created with the given constructor or if it's a primitive that is of the passed type. You can use it inside `toEqual` or `toHaveBeenCalledWith` instead of a literal value. For example, if you want to check that a mock function is called with a number:
904
882
905
883
```js
906
884
classCat {}
@@ -931,7 +909,7 @@ test('randocall calls its callback with a number', () => {
931
909
932
910
You can use it instead of a literal value:
933
911
934
-
- in `toEqual` or `toBeCalledWith`
912
+
- in `toEqual` or `toHaveBeenCalledWith`
935
913
- to match a property in `objectContaining` or `toMatchObject`
0 commit comments