From 44520c77ef1bb8c24be06aaf9638fbffe0bc3709 Mon Sep 17 00:00:00 2001 From: necipallef Date: Sat, 5 Nov 2022 02:11:01 +0300 Subject: [PATCH 1/4] docs: usingMatchers mention toStrictEqual --- website/versioned_docs/version-29.2/UsingMatchers.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/website/versioned_docs/version-29.2/UsingMatchers.md b/website/versioned_docs/version-29.2/UsingMatchers.md index c642b54f1461..64316b679017 100644 --- a/website/versioned_docs/version-29.2/UsingMatchers.md +++ b/website/versioned_docs/version-29.2/UsingMatchers.md @@ -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', () => { @@ -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', () => { From fe0118fe9ecfbc6b4a0c76b3e7679f7198fa67aa Mon Sep 17 00:00:00 2001 From: necipallef Date: Sat, 5 Nov 2022 02:14:16 +0300 Subject: [PATCH 2/4] docs: usingMatchers mention toStrictEqual --- docs/UsingMatchers.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/UsingMatchers.md b/docs/UsingMatchers.md index c642b54f1461..64316b679017 100644 --- a/docs/UsingMatchers.md +++ b/docs/UsingMatchers.md @@ -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', () => { @@ -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', () => { From cfdc89ad54752801cd941673546e68b80747dd80 Mon Sep 17 00:00:00 2001 From: necipallef Date: Sat, 5 Nov 2022 02:29:41 +0300 Subject: [PATCH 3/4] docs: changelog for toStrictEqual mentions --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 494e36427afb..60e49fb937e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From bd484814e31b80f5ebba81e187f1c8e86ec80372 Mon Sep 17 00:00:00 2001 From: Necip Allef Date: Mon, 7 Nov 2022 01:16:12 +0300 Subject: [PATCH 4/4] docs: usingMatchers mention toStrictEqual in old version docs --- website/versioned_docs/version-25.x/UsingMatchers.md | 10 ++++++++-- website/versioned_docs/version-26.x/UsingMatchers.md | 10 ++++++++-- website/versioned_docs/version-27.x/UsingMatchers.md | 10 ++++++++-- website/versioned_docs/version-28.x/UsingMatchers.md | 10 ++++++++-- website/versioned_docs/version-29.0/UsingMatchers.md | 10 ++++++++-- website/versioned_docs/version-29.1/UsingMatchers.md | 10 ++++++++-- 6 files changed, 48 insertions(+), 12 deletions(-) diff --git a/website/versioned_docs/version-25.x/UsingMatchers.md b/website/versioned_docs/version-25.x/UsingMatchers.md index 06db29575bf2..d7081bffc61a 100644 --- a/website/versioned_docs/version-25.x/UsingMatchers.md +++ b/website/versioned_docs/version-25.x/UsingMatchers.md @@ -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', () => { @@ -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', () => { diff --git a/website/versioned_docs/version-26.x/UsingMatchers.md b/website/versioned_docs/version-26.x/UsingMatchers.md index 8ee81fa06f82..570bd243e5dd 100644 --- a/website/versioned_docs/version-26.x/UsingMatchers.md +++ b/website/versioned_docs/version-26.x/UsingMatchers.md @@ -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', () => { @@ -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', () => { diff --git a/website/versioned_docs/version-27.x/UsingMatchers.md b/website/versioned_docs/version-27.x/UsingMatchers.md index c642b54f1461..64316b679017 100644 --- a/website/versioned_docs/version-27.x/UsingMatchers.md +++ b/website/versioned_docs/version-27.x/UsingMatchers.md @@ -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', () => { @@ -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', () => { diff --git a/website/versioned_docs/version-28.x/UsingMatchers.md b/website/versioned_docs/version-28.x/UsingMatchers.md index c642b54f1461..64316b679017 100644 --- a/website/versioned_docs/version-28.x/UsingMatchers.md +++ b/website/versioned_docs/version-28.x/UsingMatchers.md @@ -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', () => { @@ -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', () => { diff --git a/website/versioned_docs/version-29.0/UsingMatchers.md b/website/versioned_docs/version-29.0/UsingMatchers.md index c642b54f1461..64316b679017 100644 --- a/website/versioned_docs/version-29.0/UsingMatchers.md +++ b/website/versioned_docs/version-29.0/UsingMatchers.md @@ -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', () => { @@ -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', () => { diff --git a/website/versioned_docs/version-29.1/UsingMatchers.md b/website/versioned_docs/version-29.1/UsingMatchers.md index c642b54f1461..64316b679017 100644 --- a/website/versioned_docs/version-29.1/UsingMatchers.md +++ b/website/versioned_docs/version-29.1/UsingMatchers.md @@ -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', () => { @@ -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', () => {