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: usingMatchers mention toStrictEqual #13560

Merged
merged 4 commits into from Nov 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@
### Chore & Maintenance

- `[@jest/transform]` Update `convert-source-map` ([#13509](https://github.com/facebook/jest/pull/13509))
- `[docs]` Mention `toStrictEqual` in UsingMatchers docs. ([#13560](https://github.com/facebook/jest/pull/13560))

### Performance

Expand Down
10 changes: 8 additions & 2 deletions docs/UsingMatchers.md
Expand Up @@ -17,7 +17,7 @@ test('two plus two is four', () => {

In this code, `expect(2 + 2)` returns an "expectation" object. You typically won't do much with these expectation objects except call matchers on them. In this code, `.toBe(4)` is the matcher. When Jest runs, it tracks all the failing matchers so that it can print out nice error messages for you.

`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` instead:
`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` or `toStrictEqual` instead:

```js
test('object assignment', () => {
Expand All @@ -29,7 +29,13 @@ test('object assignment', () => {

`toEqual` recursively checks every field of an object or array.

You can also test for the opposite of a matcher:
:::tip

Using `toStrictEqual` is preferred over using `toEqual`. `toEqual` simply ignores `undefined` values, whereas `toStrictEqual` takes them into account.

:::

You can also test for the opposite of a matcher using `not`:

```js
test('adding positive numbers is not zero', () => {
Expand Down
10 changes: 8 additions & 2 deletions website/versioned_docs/version-25.x/UsingMatchers.md
Expand Up @@ -17,7 +17,7 @@ test('two plus two is four', () => {

In this code, `expect(2 + 2)` returns an "expectation" object. You typically won't do much with these expectation objects except call matchers on them. In this code, `.toBe(4)` is the matcher. When Jest runs, it tracks all the failing matchers so that it can print out nice error messages for you.

`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` instead:
`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` or `toStrictEqual` instead:

```js
test('object assignment', () => {
Expand All @@ -29,7 +29,13 @@ test('object assignment', () => {

`toEqual` recursively checks every field of an object or array.

You can also test for the opposite of a matcher:
:::tip

Using `toStrictEqual` is preferred over using `toEqual`. `toEqual` simply ignores `undefined` values, whereas `toStrictEqual` takes them into account.

:::

You can also test for the opposite of a matcher using `not`:

```js
test('adding positive numbers is not zero', () => {
Expand Down
10 changes: 8 additions & 2 deletions website/versioned_docs/version-26.x/UsingMatchers.md
Expand Up @@ -17,7 +17,7 @@ test('two plus two is four', () => {

In this code, `expect(2 + 2)` returns an "expectation" object. You typically won't do much with these expectation objects except call matchers on them. In this code, `.toBe(4)` is the matcher. When Jest runs, it tracks all the failing matchers so that it can print out nice error messages for you.

`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` instead:
`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` or `toStrictEqual` instead:

```js
test('object assignment', () => {
Expand All @@ -29,7 +29,13 @@ test('object assignment', () => {

`toEqual` recursively checks every field of an object or array.

You can also test for the opposite of a matcher:
:::tip

Using `toStrictEqual` is preferred over using `toEqual`. `toEqual` simply ignores `undefined` values, whereas `toStrictEqual` takes them into account.

:::

You can also test for the opposite of a matcher using `not`:

```js
test('adding positive numbers is not zero', () => {
Expand Down
10 changes: 8 additions & 2 deletions website/versioned_docs/version-27.x/UsingMatchers.md
Expand Up @@ -17,7 +17,7 @@ test('two plus two is four', () => {

In this code, `expect(2 + 2)` returns an "expectation" object. You typically won't do much with these expectation objects except call matchers on them. In this code, `.toBe(4)` is the matcher. When Jest runs, it tracks all the failing matchers so that it can print out nice error messages for you.

`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` instead:
`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` or `toStrictEqual` instead:

```js
test('object assignment', () => {
Expand All @@ -29,7 +29,13 @@ test('object assignment', () => {

`toEqual` recursively checks every field of an object or array.

You can also test for the opposite of a matcher:
:::tip

Using `toStrictEqual` is preferred over using `toEqual`. `toEqual` simply ignores `undefined` values, whereas `toStrictEqual` takes them into account.

:::

You can also test for the opposite of a matcher using `not`:

```js
test('adding positive numbers is not zero', () => {
Expand Down
10 changes: 8 additions & 2 deletions website/versioned_docs/version-28.x/UsingMatchers.md
Expand Up @@ -17,7 +17,7 @@ test('two plus two is four', () => {

In this code, `expect(2 + 2)` returns an "expectation" object. You typically won't do much with these expectation objects except call matchers on them. In this code, `.toBe(4)` is the matcher. When Jest runs, it tracks all the failing matchers so that it can print out nice error messages for you.

`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` instead:
`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` or `toStrictEqual` instead:

```js
test('object assignment', () => {
Expand All @@ -29,7 +29,13 @@ test('object assignment', () => {

`toEqual` recursively checks every field of an object or array.

You can also test for the opposite of a matcher:
:::tip

Using `toStrictEqual` is preferred over using `toEqual`. `toEqual` simply ignores `undefined` values, whereas `toStrictEqual` takes them into account.

:::

You can also test for the opposite of a matcher using `not`:

```js
test('adding positive numbers is not zero', () => {
Expand Down
10 changes: 8 additions & 2 deletions website/versioned_docs/version-29.0/UsingMatchers.md
Expand Up @@ -17,7 +17,7 @@ test('two plus two is four', () => {

In this code, `expect(2 + 2)` returns an "expectation" object. You typically won't do much with these expectation objects except call matchers on them. In this code, `.toBe(4)` is the matcher. When Jest runs, it tracks all the failing matchers so that it can print out nice error messages for you.

`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` instead:
`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` or `toStrictEqual` instead:

```js
test('object assignment', () => {
Expand All @@ -29,7 +29,13 @@ test('object assignment', () => {

`toEqual` recursively checks every field of an object or array.

You can also test for the opposite of a matcher:
:::tip

Using `toStrictEqual` is preferred over using `toEqual`. `toEqual` simply ignores `undefined` values, whereas `toStrictEqual` takes them into account.

:::

You can also test for the opposite of a matcher using `not`:

```js
test('adding positive numbers is not zero', () => {
Expand Down
10 changes: 8 additions & 2 deletions website/versioned_docs/version-29.1/UsingMatchers.md
Expand Up @@ -17,7 +17,7 @@ test('two plus two is four', () => {

In this code, `expect(2 + 2)` returns an "expectation" object. You typically won't do much with these expectation objects except call matchers on them. In this code, `.toBe(4)` is the matcher. When Jest runs, it tracks all the failing matchers so that it can print out nice error messages for you.

`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` instead:
`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` or `toStrictEqual` instead:

```js
test('object assignment', () => {
Expand All @@ -29,7 +29,13 @@ test('object assignment', () => {

`toEqual` recursively checks every field of an object or array.

You can also test for the opposite of a matcher:
:::tip

Using `toStrictEqual` is preferred over using `toEqual`. `toEqual` simply ignores `undefined` values, whereas `toStrictEqual` takes them into account.

:::

You can also test for the opposite of a matcher using `not`:

```js
test('adding positive numbers is not zero', () => {
Expand Down
10 changes: 8 additions & 2 deletions website/versioned_docs/version-29.2/UsingMatchers.md
Expand Up @@ -17,7 +17,7 @@ test('two plus two is four', () => {

In this code, `expect(2 + 2)` returns an "expectation" object. You typically won't do much with these expectation objects except call matchers on them. In this code, `.toBe(4)` is the matcher. When Jest runs, it tracks all the failing matchers so that it can print out nice error messages for you.

`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` instead:
`toBe` uses `Object.is` to test exact equality. If you want to check the value of an object, use `toEqual` or `toStrictEqual` instead:

```js
test('object assignment', () => {
Expand All @@ -29,7 +29,13 @@ test('object assignment', () => {

`toEqual` recursively checks every field of an object or array.

You can also test for the opposite of a matcher:
:::tip

Using `toStrictEqual` is preferred over using `toEqual`. `toEqual` simply ignores `undefined` values, whereas `toStrictEqual` takes them into account.

:::

You can also test for the opposite of a matcher using `not`:

```js
test('adding positive numbers is not zero', () => {
Expand Down