Skip to content

Commit fe45d4f

Browse files
committed
Merge branch 'main' into feat/programmatic-api
2 parents f6d0c5a + eac241c commit fe45d4f

File tree

67 files changed

+1529
-3346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1529
-3346
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444
- `[*]` Depend on exact versions of monorepo dependencies instead of `^` range ([#14553](https://github.com/facebook/jest/pull/14553))
4545
- `[*]` [**BREAKING**] Add ESM wrapper for all of Jest's modules ([#14661](https://github.com/jestjs/jest/pull/14661))
4646
- `[babel-jest, babel-preset-jest]` [**BREAKING**] Increase peer dependency of `@babel/core` to `^7.11` ([#14109](https://github.com/jestjs/jest/pull/14109))
47+
- `[expect]` [**BREAKING**] Remove `.toBeCalled()`, `.toBeCalledTimes()`, `.toBeCalledWith()`, `.lastCalledWith()`, `.nthCalledWith()`, `.toReturn()`, `.toReturnTimes()`, `.toReturnWith()`, `.lastReturnedWith()`, `.nthReturnedWith()` and `.toThrowError()` matcher aliases ([#14632](https://github.com/facebook/jest/pull/14632))
4748
- `[jest-cli, jest-config, @jest/types]` [**BREAKING**] Remove deprecated `--init` argument ([#14490](https://github.com/jestjs/jest/pull/14490))
49+
- `[jest-config, @jest/core, jest-util]` Upgrade `ci-info` ([#14655](https://github.com/jestjs/jest/pull/14655))
50+
- `[jest-transform]` Upgrade `write-file-atomic` ([#14274](https://github.com/jestjs/jest/pull/14274))
4851
- `[docs]` Fix typos in `CHANGELOG.md` and `packages/jest-validate/README.md` ([#14640](https://github.com/jestjs/jest/pull/14640))
4952
- `[docs]` Don't use alias matchers in docs ([#14631](https://github.com/facebook/jest/pull/14631))
5053

docs/ExpectAPI.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ Although the `.toBe` matcher **checks** referential identity, it **reports** a d
144144

145145
### `.toHaveBeenCalled()`
146146

147-
Also under the alias: `.toBeCalled()`
148-
149147
Use `.toHaveBeenCalledWith` to ensure that a mock function was called with specific arguments. The arguments are checked with the same algorithm that `.toEqual` uses.
150148

151149
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', () => {
174172

175173
### `.toHaveBeenCalledTimes(number)`
176174

177-
Also under the alias: `.toBeCalledTimes(number)`
178-
179175
Use `.toHaveBeenCalledTimes` to ensure that a mock function got called exact number of times.
180176

181177
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:
@@ -190,8 +186,6 @@ test('drinkEach drinks each drink', () => {
190186

191187
### `.toHaveBeenCalledWith(arg1, arg2, ...)`
192188

193-
Also under the alias: `.toBeCalledWith()`
194-
195189
Use `.toHaveBeenCalledWith` to ensure that a mock function was called with specific arguments. The arguments are checked with the same algorithm that `.toEqual` uses.
196190

197191
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', () => {
208202

209203
### `.toHaveBeenLastCalledWith(arg1, arg2, ...)`
210204

211-
Also under the alias: `.lastCalledWith(arg1, arg2, ...)`
212-
213205
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:
214206

215207
```js
@@ -222,8 +214,6 @@ test('applying to all flavors does mango last', () => {
222214

223215
### `.toHaveBeenNthCalledWith(nthCall, arg1, arg2, ....)`
224216

225-
Also under the alias: `.nthCalledWith(nthCall, arg1, arg2, ...)`
226-
227217
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:
228218

229219
```js
@@ -243,8 +233,6 @@ The nth argument must be positive integer starting from 1.
243233

244234
### `.toHaveReturned()`
245235

246-
Also under the alias: `.toReturn()`
247-
248236
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:
249237

250238
```js
@@ -259,8 +247,6 @@ test('drinks returns', () => {
259247

260248
### `.toHaveReturnedTimes(number)`
261249

262-
Also under the alias: `.toReturnTimes(number)`
263-
264250
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.
265251

266252
For example, let's say you have a mock `drink` that returns `true`. You can write:
@@ -278,8 +264,6 @@ test('drink returns twice', () => {
278264

279265
### `.toHaveReturnedWith(value)`
280266

281-
Also under the alias: `.toReturnWith(value)`
282-
283267
Use `.toHaveReturnedWith` to ensure that a mock function returned a specific value.
284268

285269
For example, let's say you have a mock `drink` that returns the name of the beverage that was consumed. You can write:
@@ -297,8 +281,6 @@ test('drink returns La Croix', () => {
297281

298282
### `.toHaveLastReturnedWith(value)`
299283

300-
Also under the alias: `.lastReturnedWith(value)`
301-
302284
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.
303285

304286
For example, let's say you have a mock `drink` that returns the name of the beverage that was consumed. You can write:
@@ -318,8 +300,6 @@ test('drink returns La Croix (Orange) last', () => {
318300

319301
### `.toHaveNthReturnedWith(nthCall, value)`
320302

321-
Also under the alias: `.nthReturnedWith(nthCall, value)`
322-
323303
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.
324304

325305
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', () => {
782762

783763
### `.toThrow(error?)`
784764

785-
Also under the alias: `.toThrowError(error?)`
786-
787765
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:
788766

789767
```js

e2e/__tests__/isolateModules.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test('works with mocks', () => {
4545
require("./read");
4646
});
4747
48-
expect(configGetMock).toBeCalledTimes(1);
48+
expect(configGetMock).toHaveBeenCalledTimes(1);
4949
})
5050
`,
5151
});

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"syncWorkspaceLock": true
99
}
1010
},
11-
"version": "29.7.0"
11+
"version": "30.0.0-alpha.1"
1212
}

packages/babel-jest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "babel-jest",
33
"description": "Jest plugin to use babel for transformation.",
4-
"version": "29.7.0",
4+
"version": "30.0.0-alpha.1",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/jestjs/jest.git",

packages/babel-plugin-jest-hoist/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "babel-plugin-jest-hoist",
3-
"version": "29.6.3",
3+
"version": "30.0.0-alpha.1",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/jestjs/jest.git",

packages/babel-preset-jest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "babel-preset-jest",
3-
"version": "29.6.3",
3+
"version": "30.0.0-alpha.1",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/jestjs/jest.git",

packages/create-jest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "create-jest",
33
"description": "Create a new Jest project",
4-
"version": "29.7.0",
4+
"version": "30.0.0-alpha.1",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/jestjs/jest.git",

packages/diff-sequences/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "diff-sequences",
3-
"version": "29.6.3",
3+
"version": "30.0.0-alpha.1",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/jestjs/jest.git",

packages/expect-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jest/expect-utils",
3-
"version": "29.7.0",
3+
"version": "30.0.0-alpha.1",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/jestjs/jest.git",

0 commit comments

Comments
 (0)