Skip to content

Commit

Permalink
docs: usingMatchers mention toStrictEqual (#13560)
Browse files Browse the repository at this point in the history
  • Loading branch information
necipallef committed Nov 7, 2022
1 parent f75a3aa commit 491827b
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -13,6 +13,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

0 comments on commit 491827b

Please sign in to comment.