Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: don't use alias methods #14631

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- `[babel-jest, babel-preset-jest]` [**BREAKING**] Increase peer dependency of `@babel/core` to `^7.11` ([#14109](https://github.com/jestjs/jest/pull/14109))
- `[jest-cli, jest-config, @jest/types]` [**BREAKING**] Remove deprecated `--init` argument ([#14490](https://github.com/jestjs/jest/pull/14490))
- `[docs]` Fix typos in `CHANGELOG.md` and `packages/jest-validate/README.md` ([#14640](https://github.com/jestjs/jest/pull/14640))
- `[docs]` Don't use alias matchers in docs ([#14631](https://github.com/facebook/jest/pull/14631))

## 29.7.0

Expand Down
8 changes: 4 additions & 4 deletions docs/ExpectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ Check out the section on [Inline Snapshots](SnapshotTesting.md#inline-snapshots)

### `expect.anything()`

`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:
`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:

```js
test('map calls its argument with a non-null argument', () => {
Expand All @@ -900,7 +900,7 @@ test('map calls its argument with a non-null argument', () => {

### `expect.any(constructor)`

`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:
`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:

```js
class Cat {}
Expand Down Expand Up @@ -931,7 +931,7 @@ test('randocall calls its callback with a number', () => {

You can use it instead of a literal value:

- in `toEqual` or `toBeCalledWith`
- in `toEqual` or `toHaveBeenCalledWith`
- to match a property in `objectContaining` or `toMatchObject`

```js
Expand Down Expand Up @@ -1063,7 +1063,7 @@ describe('not.stringContaining', () => {

You can use it instead of a literal value:

- in `toEqual` or `toBeCalledWith`
- in `toEqual` or `toHaveBeenCalledWith`
- to match an element in `arrayContaining`
- to match a property in `objectContaining` or `toMatchObject`

Expand Down
14 changes: 7 additions & 7 deletions docs/TimerMocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ test('calls the callback after 1 second', () => {
timerGame(callback);

// At this point in time, the callback should not have been called yet
expect(callback).not.toBeCalled();
expect(callback).not.toHaveBeenCalled();

// Fast-forward until all timers have been executed
jest.runAllTimers();

// Now our callback should have been called!
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();
expect(callback).toHaveBeenCalledTimes(1);
});
```
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('infiniteTimerGame', () => {
jest.runOnlyPendingTimers();

// At this point, our 1-second timer should have fired its callback
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();

// And it should have created a new timer to start the game over in
// 10 seconds
Expand Down Expand Up @@ -154,13 +154,13 @@ it('calls the callback after 1 second via advanceTimersByTime', () => {
timerGame(callback);

// At this point in time, the callback should not have been called yet
expect(callback).not.toBeCalled();
expect(callback).not.toHaveBeenCalled();

// Fast-forward until all timers have been executed
jest.advanceTimersByTime(1000);

// Now our callback should have been called!
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();
expect(callback).toHaveBeenCalledTimes(1);
});
```
Expand All @@ -181,12 +181,12 @@ it('calls the animation frame callback after advanceTimersToNextFrame()', () =>
requestAnimationFrame(callback);

// At this point in time, the callback should not have been called yet
expect(callback).not.toBeCalled();
expect(callback).not.toHaveBeenCalled();

jest.advanceTimersToNextFrame();

// Now our callback should have been called!
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();
expect(callback).toHaveBeenCalledTimes(1);
});
```
Expand Down
2 changes: 1 addition & 1 deletion docs/TutorialjQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test('displays a user after a click', () => {

// Assert that the fetchCurrentUser function was called, and that the
// #username span's inner text was updated as we'd expect it to.
expect(fetchCurrentUser).toBeCalled();
expect(fetchCurrentUser).toHaveBeenCalled();
expect($('#username').text()).toBe('Johnny Cash - Logged In');
});
```
Expand Down
8 changes: 4 additions & 4 deletions website/versioned_docs/version-29.4/ExpectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ Check out the section on [Inline Snapshots](SnapshotTesting.md#inline-snapshots)

### `expect.anything()`

`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:
`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:

```js
test('map calls its argument with a non-null argument', () => {
Expand All @@ -900,7 +900,7 @@ test('map calls its argument with a non-null argument', () => {

### `expect.any(constructor)`

`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:
`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:

```js
class Cat {}
Expand Down Expand Up @@ -931,7 +931,7 @@ test('randocall calls its callback with a number', () => {

You can use it instead of a literal value:

- in `toEqual` or `toBeCalledWith`
- in `toEqual` or `toHaveBeenCalledWith`
- to match a property in `objectContaining` or `toMatchObject`

```js
Expand Down Expand Up @@ -1063,7 +1063,7 @@ describe('not.stringContaining', () => {

You can use it instead of a literal value:

- in `toEqual` or `toBeCalledWith`
- in `toEqual` or `toHaveBeenCalledWith`
- to match an element in `arrayContaining`
- to match a property in `objectContaining` or `toMatchObject`

Expand Down
10 changes: 5 additions & 5 deletions website/versioned_docs/version-29.4/TimerMocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ test('calls the callback after 1 second', () => {
timerGame(callback);

// At this point in time, the callback should not have been called yet
expect(callback).not.toBeCalled();
expect(callback).not.toHaveBeenCalled();

// Fast-forward until all timers have been executed
jest.runAllTimers();

// Now our callback should have been called!
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();
expect(callback).toHaveBeenCalledTimes(1);
});
```
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('infiniteTimerGame', () => {
jest.runOnlyPendingTimers();

// At this point, our 1-second timer should have fired its callback
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();

// And it should have created a new timer to start the game over in
// 10 seconds
Expand Down Expand Up @@ -154,13 +154,13 @@ it('calls the callback after 1 second via advanceTimersByTime', () => {
timerGame(callback);

// At this point in time, the callback should not have been called yet
expect(callback).not.toBeCalled();
expect(callback).not.toHaveBeenCalled();

// Fast-forward until all timers have been executed
jest.advanceTimersByTime(1000);

// Now our callback should have been called!
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();
expect(callback).toHaveBeenCalledTimes(1);
});
```
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-29.4/TutorialjQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test('displays a user after a click', () => {

// Assert that the fetchCurrentUser function was called, and that the
// #username span's inner text was updated as we'd expect it to.
expect(fetchCurrentUser).toBeCalled();
expect(fetchCurrentUser).toHaveBeenCalled();
expect($('#username').text()).toBe('Johnny Cash - Logged In');
});
```
Expand Down
8 changes: 4 additions & 4 deletions website/versioned_docs/version-29.5/ExpectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ Check out the section on [Inline Snapshots](SnapshotTesting.md#inline-snapshots)

### `expect.anything()`

`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:
`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:

```js
test('map calls its argument with a non-null argument', () => {
Expand All @@ -900,7 +900,7 @@ test('map calls its argument with a non-null argument', () => {

### `expect.any(constructor)`

`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:
`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:

```js
class Cat {}
Expand Down Expand Up @@ -931,7 +931,7 @@ test('randocall calls its callback with a number', () => {

You can use it instead of a literal value:

- in `toEqual` or `toBeCalledWith`
- in `toEqual` or `toHaveBeenCalledWith`
- to match a property in `objectContaining` or `toMatchObject`

```js
Expand Down Expand Up @@ -1063,7 +1063,7 @@ describe('not.stringContaining', () => {

You can use it instead of a literal value:

- in `toEqual` or `toBeCalledWith`
- in `toEqual` or `toHaveBeenCalledWith`
- to match an element in `arrayContaining`
- to match a property in `objectContaining` or `toMatchObject`

Expand Down
10 changes: 5 additions & 5 deletions website/versioned_docs/version-29.5/TimerMocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ test('calls the callback after 1 second', () => {
timerGame(callback);

// At this point in time, the callback should not have been called yet
expect(callback).not.toBeCalled();
expect(callback).not.toHaveBeenCalled();

// Fast-forward until all timers have been executed
jest.runAllTimers();

// Now our callback should have been called!
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();
expect(callback).toHaveBeenCalledTimes(1);
});
```
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('infiniteTimerGame', () => {
jest.runOnlyPendingTimers();

// At this point, our 1-second timer should have fired its callback
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();

// And it should have created a new timer to start the game over in
// 10 seconds
Expand Down Expand Up @@ -154,13 +154,13 @@ it('calls the callback after 1 second via advanceTimersByTime', () => {
timerGame(callback);

// At this point in time, the callback should not have been called yet
expect(callback).not.toBeCalled();
expect(callback).not.toHaveBeenCalled();

// Fast-forward until all timers have been executed
jest.advanceTimersByTime(1000);

// Now our callback should have been called!
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();
expect(callback).toHaveBeenCalledTimes(1);
});
```
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-29.5/TutorialjQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test('displays a user after a click', () => {

// Assert that the fetchCurrentUser function was called, and that the
// #username span's inner text was updated as we'd expect it to.
expect(fetchCurrentUser).toBeCalled();
expect(fetchCurrentUser).toHaveBeenCalled();
expect($('#username').text()).toBe('Johnny Cash - Logged In');
});
```
Expand Down
8 changes: 4 additions & 4 deletions website/versioned_docs/version-29.6/ExpectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ Check out the section on [Inline Snapshots](SnapshotTesting.md#inline-snapshots)

### `expect.anything()`

`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:
`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:

```js
test('map calls its argument with a non-null argument', () => {
Expand All @@ -900,7 +900,7 @@ test('map calls its argument with a non-null argument', () => {

### `expect.any(constructor)`

`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:
`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:

```js
class Cat {}
Expand Down Expand Up @@ -931,7 +931,7 @@ test('randocall calls its callback with a number', () => {

You can use it instead of a literal value:

- in `toEqual` or `toBeCalledWith`
- in `toEqual` or `toHaveBeenCalledWith`
- to match a property in `objectContaining` or `toMatchObject`

```js
Expand Down Expand Up @@ -1063,7 +1063,7 @@ describe('not.stringContaining', () => {

You can use it instead of a literal value:

- in `toEqual` or `toBeCalledWith`
- in `toEqual` or `toHaveBeenCalledWith`
- to match an element in `arrayContaining`
- to match a property in `objectContaining` or `toMatchObject`

Expand Down
10 changes: 5 additions & 5 deletions website/versioned_docs/version-29.6/TimerMocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ test('calls the callback after 1 second', () => {
timerGame(callback);

// At this point in time, the callback should not have been called yet
expect(callback).not.toBeCalled();
expect(callback).not.toHaveBeenCalled();

// Fast-forward until all timers have been executed
jest.runAllTimers();

// Now our callback should have been called!
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();
expect(callback).toHaveBeenCalledTimes(1);
});
```
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('infiniteTimerGame', () => {
jest.runOnlyPendingTimers();

// At this point, our 1-second timer should have fired its callback
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();

// And it should have created a new timer to start the game over in
// 10 seconds
Expand Down Expand Up @@ -154,13 +154,13 @@ it('calls the callback after 1 second via advanceTimersByTime', () => {
timerGame(callback);

// At this point in time, the callback should not have been called yet
expect(callback).not.toBeCalled();
expect(callback).not.toHaveBeenCalled();

// Fast-forward until all timers have been executed
jest.advanceTimersByTime(1000);

// Now our callback should have been called!
expect(callback).toBeCalled();
expect(callback).toHaveBeenCalled();
expect(callback).toHaveBeenCalledTimes(1);
});
```
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-29.6/TutorialjQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test('displays a user after a click', () => {

// Assert that the fetchCurrentUser function was called, and that the
// #username span's inner text was updated as we'd expect it to.
expect(fetchCurrentUser).toBeCalled();
expect(fetchCurrentUser).toHaveBeenCalled();
expect($('#username').text()).toBe('Johnny Cash - Logged In');
});
```
Expand Down
Loading