From 04b43d982d18acee35562b12a8e10a5a9cee715e Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Mon, 8 Apr 2019 13:44:44 -0400 Subject: [PATCH 1/2] chore: Fix label and add opposite assertion for toEqual tests --- .../__snapshots__/matchers.test.js.snap | 685 +++++++++--------- .../expect/src/__tests__/matchers.test.js | 15 +- 2 files changed, 343 insertions(+), 357 deletions(-) diff --git a/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap b/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap index b1234a0c609b..ce7e40e101f6 100644 --- a/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap +++ b/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap @@ -1827,13 +1827,6 @@ exports[`.toContain(), .toContainEqual() error cases for toContainEqual 1`] = ` Received has value: null" `; -exports[`.toEqual() {pass: false} expect("Alice").not.toEqual({"asymmetricMatch": [Function asymmetricMatch]}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: {\\"asymmetricMatch\\": [Function asymmetricMatch]} -Received: \\"Alice\\"" -`; - exports[`.toEqual() {pass: false} expect("Eve").toEqual({"asymmetricMatch": [Function asymmetricMatch]}) 1`] = ` "expect(received).toEqual(expected) @@ -1841,34 +1834,6 @@ Expected: {\\"asymmetricMatch\\": [Function asymmetricMatch]} Received: \\"Eve\\"" `; -exports[`.toEqual() {pass: false} expect("abc").not.toEqual("abc") 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: \\"abc\\" -Received: \\"abc\\"" -`; - -exports[`.toEqual() {pass: false} expect("abc").not.toEqual({"0": "a", "1": "b", "2": "c"}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: {\\"0\\": \\"a\\", \\"1\\": \\"b\\", \\"2\\": \\"c\\"} -Received: \\"abc\\"" -`; - -exports[`.toEqual() {pass: false} expect("abcd").not.toEqual(StringContaining "bc") 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: StringContaining \\"bc\\" -Received: \\"abcd\\"" -`; - -exports[`.toEqual() {pass: false} expect("abcd").not.toEqual(StringMatching /bc/) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: StringMatching /bc/ -Received: \\"abcd\\"" -`; - exports[`.toEqual() {pass: false} expect("abd").toEqual(StringContaining "bc") 1`] = ` "expect(received).toEqual(expected) @@ -1895,20 +1860,6 @@ Difference: + banana" `; -exports[`.toEqual() {pass: false} expect([1, 2, 3]).not.toEqual(ArrayContaining [2, 3]) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: ArrayContaining [2, 3] -Received: [1, 2, 3]" -`; - -exports[`.toEqual() {pass: false} expect([1, 2]).not.toEqual([1, 2]) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: [1, 2] -Received: [1, 2]" -`; - exports[`.toEqual() {pass: false} expect([1, 2]).toEqual([2, 1]) 1`] = ` "expect(received).toEqual(expected) @@ -1940,13 +1891,6 @@ Difference: ]" `; -exports[`.toEqual() {pass: false} expect([1]).not.toEqual([1]) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: [1] -Received: [1]" -`; - exports[`.toEqual() {pass: false} expect([1]).toEqual([2]) 1`] = ` "expect(received).toEqual(expected) @@ -1961,34 +1905,6 @@ Difference: ]" `; -exports[`.toEqual() {pass: false} expect([Function anonymous]).not.toEqual(Any) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Any -Received: [Function anonymous]" -`; - -exports[`.toEqual() {pass: false} expect({"0": "a", "1": "b", "2": "c"}).not.toEqual("abc") 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: \\"abc\\" -Received: {\\"0\\": \\"a\\", \\"1\\": \\"b\\", \\"2\\": \\"c\\"}" -`; - -exports[`.toEqual() {pass: false} expect({"a": 1, "b": [Function b], "c": true}).not.toEqual({"a": 1, "b": Any, "c": Anything}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: {\\"a\\": 1, \\"b\\": Any, \\"c\\": Anything} -Received: {\\"a\\": 1, \\"b\\": [Function b], \\"c\\": true}" -`; - -exports[`.toEqual() {pass: false} expect({"a": 1, "b": 2}).not.toEqual(ObjectContaining {"a": 1}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: ObjectContaining {\\"a\\": 1} -Received: {\\"a\\": 1, \\"b\\": 2}" -`; - exports[`.toEqual() {pass: false} expect({"a": 1, "b": 2}).toEqual(ObjectContaining {"a": 2}) 1`] = ` "expect(received).toEqual(expected) @@ -2005,7 +1921,7 @@ Difference: }" `; -exports[`.toEqual() {pass: false} expect({"a": 5}).toEqual({"b": 6}) 1`] = ` +exports[`.toEqual() {pass: false} expect({"a": 1}).toEqual({"a": 2}) 1`] = ` "expect(received).toEqual(expected) Difference: @@ -2014,23 +1930,23 @@ Difference: + Received Object { -- \\"b\\": 6, -+ \\"a\\": 5, +- \\"a\\": 2, ++ \\"a\\": 1, }" `; -exports[`.toEqual() {pass: false} expect({"a": 99}).not.toEqual({"a": 99}) 1`] = ` -"expect(received).not.toEqual(expected) +exports[`.toEqual() {pass: false} expect({"a": 5}).toEqual({"b": 6}) 1`] = ` +"expect(received).toEqual(expected) -Expected: {\\"a\\": 99} -Received: {\\"a\\": 99}" -`; +Difference: -exports[`.toEqual() {pass: false} expect({"nodeName": "div", "nodeType": 1}).not.toEqual({"nodeName": "div", "nodeType": 1}) 1`] = ` -"expect(received).not.toEqual(expected) +- Expected ++ Received -Expected: {\\"nodeName\\": \\"div\\", \\"nodeType\\": 1} -Received: {\\"nodeName\\": \\"div\\", \\"nodeType\\": 1}" + Object { +- \\"b\\": 6, ++ \\"a\\": 5, + }" `; exports[`.toEqual() {pass: false} expect({"nodeName": "div", "nodeType": 1}).toEqual({"nodeName": "p", "nodeType": 1}) 1`] = ` @@ -2065,27 +1981,6 @@ Difference: }" `; -exports[`.toEqual() {pass: false} expect({}).not.toEqual({}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: {} -Received: {}" -`; - -exports[`.toEqual() {pass: false} expect({}).not.toEqual(0) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: 0 -Received: {}" -`; - -exports[`.toEqual() {pass: false} expect(0).not.toEqual({}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: {} -Received: 0" -`; - exports[`.toEqual() {pass: false} expect(0).toEqual(-0) 1`] = ` "expect(received).toEqual(expected) @@ -2100,13 +1995,6 @@ Expected: 5e-324 Received: 0" `; -exports[`.toEqual() {pass: false} expect(1).not.toEqual(1) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: 1 -Received: 1" -`; - exports[`.toEqual() {pass: false} expect(1).toEqual(2) 1`] = ` "expect(received).toEqual(expected) @@ -2128,13 +2016,6 @@ Expected: 0 Received: 5e-324" `; -exports[`.toEqual() {pass: false} expect(Immutable.List [1, 2]).not.toEqual(Immutable.List [1, 2]) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Immutable.List [1, 2] -Received: Immutable.List [1, 2]" -`; - exports[`.toEqual() {pass: false} expect(Immutable.List [1, 2]).toEqual(Immutable.List [2, 1]) 1`] = ` "expect(received).toEqual(expected) @@ -2150,13 +2031,6 @@ Difference: ]" `; -exports[`.toEqual() {pass: false} expect(Immutable.List [1]).not.toEqual(Immutable.List [1]) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Immutable.List [1] -Received: Immutable.List [1]" -`; - exports[`.toEqual() {pass: false} expect(Immutable.List [1]).toEqual(Immutable.List [2]) 1`] = ` "expect(received).toEqual(expected) @@ -2171,13 +2045,6 @@ Difference: ]" `; -exports[`.toEqual() {pass: false} expect(Immutable.Map {"1": Immutable.Map {"2": {"a": 99}}}).not.toEqual(Immutable.Map {"1": Immutable.Map {"2": {"a": 99}}}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Immutable.Map {\\"1\\": Immutable.Map {\\"2\\": {\\"a\\": 99}}} -Received: Immutable.Map {\\"1\\": Immutable.Map {\\"2\\": {\\"a\\": 99}}}" -`; - exports[`.toEqual() {pass: false} expect(Immutable.Map {"1": Immutable.Map {"2": {"a": 99}}}).toEqual(Immutable.Map {"1": Immutable.Map {"2": {"a": 11}}}) 1`] = ` "expect(received).toEqual(expected) @@ -2224,34 +2091,6 @@ Difference: }" `; -exports[`.toEqual() {pass: false} expect(Immutable.Map {}).not.toEqual(Immutable.Map {}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Immutable.Map {} -Received: Immutable.Map {}" -`; - -exports[`.toEqual() {pass: false} expect(Immutable.Map {1: "one", 2: "two"}).not.toEqual(Immutable.Map {1: "one", 2: "two"}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Immutable.Map {1: \\"one\\", 2: \\"two\\"} -Received: Immutable.Map {1: \\"one\\", 2: \\"two\\"}" -`; - -exports[`.toEqual() {pass: false} expect(Immutable.Map {1: "one", 2: "two"}).not.toEqual(Immutable.Map {2: "two", 1: "one"}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Immutable.Map {2: \\"two\\", 1: \\"one\\"} -Received: Immutable.Map {1: \\"one\\", 2: \\"two\\"}" -`; - -exports[`.toEqual() {pass: false} expect(Immutable.OrderedMap {1: "one", 2: "two"}).not.toEqual(Immutable.OrderedMap {1: "one", 2: "two"}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Immutable.OrderedMap {1: \\"one\\", 2: \\"two\\"} -Received: Immutable.OrderedMap {1: \\"one\\", 2: \\"two\\"}" -`; - exports[`.toEqual() {pass: false} expect(Immutable.OrderedMap {1: "one", 2: "two"}).toEqual(Immutable.OrderedMap {2: "two", 1: "one"}) 1`] = ` "expect(received).toEqual(expected) @@ -2267,20 +2106,6 @@ Difference: }" `; -exports[`.toEqual() {pass: false} expect(Immutable.OrderedSet []).not.toEqual(Immutable.OrderedSet []) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Immutable.OrderedSet [] -Received: Immutable.OrderedSet []" -`; - -exports[`.toEqual() {pass: false} expect(Immutable.OrderedSet [1, 2]).not.toEqual(Immutable.OrderedSet [1, 2]) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Immutable.OrderedSet [1, 2] -Received: Immutable.OrderedSet [1, 2]" -`; - exports[`.toEqual() {pass: false} expect(Immutable.OrderedSet [1, 2]).toEqual(Immutable.OrderedSet [2, 1]) 1`] = ` "expect(received).toEqual(expected) @@ -2296,27 +2121,6 @@ Difference: ]" `; -exports[`.toEqual() {pass: false} expect(Immutable.Set []).not.toEqual(Immutable.Set []) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Immutable.Set [] -Received: Immutable.Set []" -`; - -exports[`.toEqual() {pass: false} expect(Immutable.Set [1, 2]).not.toEqual(Immutable.Set [1, 2]) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Immutable.Set [1, 2] -Received: Immutable.Set [1, 2]" -`; - -exports[`.toEqual() {pass: false} expect(Immutable.Set [1, 2]).not.toEqual(Immutable.Set [2, 1]) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Immutable.Set [2, 1] -Received: Immutable.Set [1, 2]" -`; - exports[`.toEqual() {pass: false} expect(Immutable.Set [1, 2]).toEqual(Immutable.Set []) 1`] = ` "expect(received).toEqual(expected) @@ -2391,27 +2195,6 @@ Difference: }" `; -exports[`.toEqual() {pass: false} expect(Map {[1] => "one", [2] => "two", [3] => "three", [3] => "four"}).not.toEqual(Map {[3] => "three", [3] => "four", [2] => "two", [1] => "one"}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Map {[3] => \\"three\\", [3] => \\"four\\", [2] => \\"two\\", [1] => \\"one\\"} -Received: Map {[1] => \\"one\\", [2] => \\"two\\", [3] => \\"three\\", [3] => \\"four\\"}" -`; - -exports[`.toEqual() {pass: false} expect(Map {[1] => "one", [2] => "two"}).not.toEqual(Map {[2] => "two", [1] => "one"}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Map {[2] => \\"two\\", [1] => \\"one\\"} -Received: Map {[1] => \\"one\\", [2] => \\"two\\"}" -`; - -exports[`.toEqual() {pass: false} expect(Map {[1] => Map {[1] => "one"}, [2] => Map {[2] => "two"}}).not.toEqual(Map {[2] => Map {[2] => "two"}, [1] => Map {[1] => "one"}}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Map {[2] => Map {[2] => \\"two\\"}, [1] => Map {[1] => \\"one\\"}} -Received: Map {[1] => Map {[1] => \\"one\\"}, [2] => Map {[2] => \\"two\\"}}" -`; - exports[`.toEqual() {pass: false} expect(Map {[1] => Map {[1] => "one"}}).toEqual(Map {[1] => Map {[1] => "two"}}) 1`] = ` "expect(received).toEqual(expected) @@ -2432,20 +2215,6 @@ Difference: }" `; -exports[`.toEqual() {pass: false} expect(Map {{"a": 1} => "one", {"b": 2} => "two"}).not.toEqual(Map {{"b": 2} => "two", {"a": 1} => "one"}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Map {{\\"b\\": 2} => \\"two\\", {\\"a\\": 1} => \\"one\\"} -Received: Map {{\\"a\\": 1} => \\"one\\", {\\"b\\": 2} => \\"two\\"}" -`; - -exports[`.toEqual() {pass: false} expect(Map {}).not.toEqual(Map {}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Map {} -Received: Map {}" -`; - exports[`.toEqual() {pass: false} expect(Map {}).toEqual(Set {}) 1`] = ` "expect(received).toEqual(expected) @@ -2453,20 +2222,6 @@ Expected: Set {} Received: Map {}" `; -exports[`.toEqual() {pass: false} expect(Map {1 => "one", 2 => "two"}).not.toEqual(Map {1 => "one", 2 => "two"}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Map {1 => \\"one\\", 2 => \\"two\\"} -Received: Map {1 => \\"one\\", 2 => \\"two\\"}" -`; - -exports[`.toEqual() {pass: false} expect(Map {1 => "one", 2 => "two"}).not.toEqual(Map {2 => "two", 1 => "one"}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Map {2 => \\"two\\", 1 => \\"one\\"} -Received: Map {1 => \\"one\\", 2 => \\"two\\"}" -`; - exports[`.toEqual() {pass: false} expect(Map {1 => "one", 2 => "two"}).toEqual(Map {1 => "one"}) 1`] = ` "expect(received).toEqual(expected) @@ -2481,34 +2236,6 @@ Difference: }" `; -exports[`.toEqual() {pass: false} expect(Map {1 => ["one"], 2 => ["two"]}).not.toEqual(Map {2 => ["two"], 1 => ["one"]}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Map {2 => [\\"two\\"], 1 => [\\"one\\"]} -Received: Map {1 => [\\"one\\"], 2 => [\\"two\\"]}" -`; - -exports[`.toEqual() {pass: false} expect(NaN).not.toEqual(NaN) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: NaN -Received: NaN" -`; - -exports[`.toEqual() {pass: false} expect(Set {[1], [2], [3], [3]}).not.toEqual(Set {[3], [3], [2], [1]}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Set {[3], [3], [2], [1]} -Received: Set {[1], [2], [3], [3]}" -`; - -exports[`.toEqual() {pass: false} expect(Set {[1], [2]}).not.toEqual(Set {[2], [1]}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Set {[2], [1]} -Received: Set {[1], [2]}" -`; - exports[`.toEqual() {pass: false} expect(Set {[1], [2]}).toEqual(Set {[1], [2], [2]}) 1`] = ` "expect(received).toEqual(expected) @@ -2549,34 +2276,6 @@ Difference: }" `; -exports[`.toEqual() {pass: false} expect(Set {{"a": 1}, {"b": 2}}).not.toEqual(Set {{"b": 2}, {"a": 1}}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Set {{\\"b\\": 2}, {\\"a\\": 1}} -Received: Set {{\\"a\\": 1}, {\\"b\\": 2}}" -`; - -exports[`.toEqual() {pass: false} expect(Set {}).not.toEqual(Set {}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Set {} -Received: Set {}" -`; - -exports[`.toEqual() {pass: false} expect(Set {1, 2}).not.toEqual(Set {1, 2}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Set {1, 2} -Received: Set {1, 2}" -`; - -exports[`.toEqual() {pass: false} expect(Set {1, 2}).not.toEqual(Set {2, 1}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Set {2, 1} -Received: Set {1, 2}" -`; - exports[`.toEqual() {pass: false} expect(Set {1, 2}).toEqual(Set {}) 1`] = ` "expect(received).toEqual(expected) @@ -2607,13 +2306,6 @@ Difference: }" `; -exports[`.toEqual() {pass: false} expect(Set {Set {[1]}, Set {[2]}}).not.toEqual(Set {Set {[2]}, Set {[1]}}) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Set {Set {[2]}, Set {[1]}} -Received: Set {Set {[1]}, Set {[2]}}" -`; - exports[`.toEqual() {pass: false} expect(Set {Set {1}, Set {2}}).toEqual(Set {Set {1}, Set {3}}) 1`] = ` "expect(received).toEqual(expected) @@ -2647,20 +2339,6 @@ Expected: undefined Received: null" `; -exports[`.toEqual() {pass: false} expect(true).not.toEqual(Anything) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: Anything -Received: true" -`; - -exports[`.toEqual() {pass: false} expect(true).not.toEqual(true) 1`] = ` -"expect(received).not.toEqual(expected) - -Expected: true -Received: true" -`; - exports[`.toEqual() {pass: false} expect(true).toEqual(false) 1`] = ` "expect(received).toEqual(expected) @@ -2682,25 +2360,340 @@ Expected: Anything Received: undefined" `; -exports[`.toEqual() failure message matches the expected snapshot 1`] = ` -"expect(received).toEqual(expected) +exports[`.toEqual() {pass: true} expect("Alice").not.toEqual({"asymmetricMatch": [Function asymmetricMatch]}) 1`] = ` +"expect(received).not.toEqual(expected) -Difference: +Expected: {\\"asymmetricMatch\\": [Function asymmetricMatch]} +Received: \\"Alice\\"" +`; -- Expected -+ Received +exports[`.toEqual() {pass: true} expect("abc").not.toEqual("abc") 1`] = ` +"expect(received).not.toEqual(expected) - Object { -- \\"a\\": 2, -+ \\"a\\": 1, - }" +Expected: \\"abc\\" +Received: \\"abc\\"" `; -exports[`.toEqual() failure message matches the expected snapshot 2`] = ` +exports[`.toEqual() {pass: true} expect("abc").not.toEqual({"0": "a", "1": "b", "2": "c"}) 1`] = ` "expect(received).not.toEqual(expected) -Expected: {\\"a\\": 1} -Received: {\\"a\\": 1}" +Expected: {\\"0\\": \\"a\\", \\"1\\": \\"b\\", \\"2\\": \\"c\\"} +Received: \\"abc\\"" +`; + +exports[`.toEqual() {pass: true} expect("abcd").not.toEqual(StringContaining "bc") 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: StringContaining \\"bc\\" +Received: \\"abcd\\"" +`; + +exports[`.toEqual() {pass: true} expect("abcd").not.toEqual(StringMatching /bc/) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: StringMatching /bc/ +Received: \\"abcd\\"" +`; + +exports[`.toEqual() {pass: true} expect([1, 2, 3]).not.toEqual(ArrayContaining [2, 3]) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: ArrayContaining [2, 3] +Received: [1, 2, 3]" +`; + +exports[`.toEqual() {pass: true} expect([1, 2]).not.toEqual([1, 2]) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: [1, 2] +Received: [1, 2]" +`; + +exports[`.toEqual() {pass: true} expect([1]).not.toEqual([1]) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: [1] +Received: [1]" +`; + +exports[`.toEqual() {pass: true} expect([Function anonymous]).not.toEqual(Any) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Any +Received: [Function anonymous]" +`; + +exports[`.toEqual() {pass: true} expect({"0": "a", "1": "b", "2": "c"}).not.toEqual("abc") 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: \\"abc\\" +Received: {\\"0\\": \\"a\\", \\"1\\": \\"b\\", \\"2\\": \\"c\\"}" +`; + +exports[`.toEqual() {pass: true} expect({"a": 1, "b": [Function b], "c": true}).not.toEqual({"a": 1, "b": Any, "c": Anything}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: {\\"a\\": 1, \\"b\\": Any, \\"c\\": Anything} +Received: {\\"a\\": 1, \\"b\\": [Function b], \\"c\\": true}" +`; + +exports[`.toEqual() {pass: true} expect({"a": 1, "b": 2}).not.toEqual(ObjectContaining {"a": 1}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: ObjectContaining {\\"a\\": 1} +Received: {\\"a\\": 1, \\"b\\": 2}" +`; + +exports[`.toEqual() {pass: true} expect({"a": 99}).not.toEqual({"a": 99}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: {\\"a\\": 99} +Received: {\\"a\\": 99}" +`; + +exports[`.toEqual() {pass: true} expect({"nodeName": "div", "nodeType": 1}).not.toEqual({"nodeName": "div", "nodeType": 1}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: {\\"nodeName\\": \\"div\\", \\"nodeType\\": 1} +Received: {\\"nodeName\\": \\"div\\", \\"nodeType\\": 1}" +`; + +exports[`.toEqual() {pass: true} expect({}).not.toEqual({}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: {} +Received: {}" +`; + +exports[`.toEqual() {pass: true} expect({}).not.toEqual(0) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: 0 +Received: {}" +`; + +exports[`.toEqual() {pass: true} expect(0).not.toEqual({}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: {} +Received: 0" +`; + +exports[`.toEqual() {pass: true} expect(1).not.toEqual(1) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: 1 +Received: 1" +`; + +exports[`.toEqual() {pass: true} expect(Immutable.List [1, 2]).not.toEqual(Immutable.List [1, 2]) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Immutable.List [1, 2] +Received: Immutable.List [1, 2]" +`; + +exports[`.toEqual() {pass: true} expect(Immutable.List [1]).not.toEqual(Immutable.List [1]) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Immutable.List [1] +Received: Immutable.List [1]" +`; + +exports[`.toEqual() {pass: true} expect(Immutable.Map {"1": Immutable.Map {"2": {"a": 99}}}).not.toEqual(Immutable.Map {"1": Immutable.Map {"2": {"a": 99}}}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Immutable.Map {\\"1\\": Immutable.Map {\\"2\\": {\\"a\\": 99}}} +Received: Immutable.Map {\\"1\\": Immutable.Map {\\"2\\": {\\"a\\": 99}}}" +`; + +exports[`.toEqual() {pass: true} expect(Immutable.Map {}).not.toEqual(Immutable.Map {}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Immutable.Map {} +Received: Immutable.Map {}" +`; + +exports[`.toEqual() {pass: true} expect(Immutable.Map {1: "one", 2: "two"}).not.toEqual(Immutable.Map {1: "one", 2: "two"}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Immutable.Map {1: \\"one\\", 2: \\"two\\"} +Received: Immutable.Map {1: \\"one\\", 2: \\"two\\"}" +`; + +exports[`.toEqual() {pass: true} expect(Immutable.Map {1: "one", 2: "two"}).not.toEqual(Immutable.Map {2: "two", 1: "one"}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Immutable.Map {2: \\"two\\", 1: \\"one\\"} +Received: Immutable.Map {1: \\"one\\", 2: \\"two\\"}" +`; + +exports[`.toEqual() {pass: true} expect(Immutable.OrderedMap {1: "one", 2: "two"}).not.toEqual(Immutable.OrderedMap {1: "one", 2: "two"}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Immutable.OrderedMap {1: \\"one\\", 2: \\"two\\"} +Received: Immutable.OrderedMap {1: \\"one\\", 2: \\"two\\"}" +`; + +exports[`.toEqual() {pass: true} expect(Immutable.OrderedSet []).not.toEqual(Immutable.OrderedSet []) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Immutable.OrderedSet [] +Received: Immutable.OrderedSet []" +`; + +exports[`.toEqual() {pass: true} expect(Immutable.OrderedSet [1, 2]).not.toEqual(Immutable.OrderedSet [1, 2]) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Immutable.OrderedSet [1, 2] +Received: Immutable.OrderedSet [1, 2]" +`; + +exports[`.toEqual() {pass: true} expect(Immutable.Set []).not.toEqual(Immutable.Set []) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Immutable.Set [] +Received: Immutable.Set []" +`; + +exports[`.toEqual() {pass: true} expect(Immutable.Set [1, 2]).not.toEqual(Immutable.Set [1, 2]) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Immutable.Set [1, 2] +Received: Immutable.Set [1, 2]" +`; + +exports[`.toEqual() {pass: true} expect(Immutable.Set [1, 2]).not.toEqual(Immutable.Set [2, 1]) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Immutable.Set [2, 1] +Received: Immutable.Set [1, 2]" +`; + +exports[`.toEqual() {pass: true} expect(Map {[1] => "one", [2] => "two", [3] => "three", [3] => "four"}).not.toEqual(Map {[3] => "three", [3] => "four", [2] => "two", [1] => "one"}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Map {[3] => \\"three\\", [3] => \\"four\\", [2] => \\"two\\", [1] => \\"one\\"} +Received: Map {[1] => \\"one\\", [2] => \\"two\\", [3] => \\"three\\", [3] => \\"four\\"}" +`; + +exports[`.toEqual() {pass: true} expect(Map {[1] => "one", [2] => "two"}).not.toEqual(Map {[2] => "two", [1] => "one"}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Map {[2] => \\"two\\", [1] => \\"one\\"} +Received: Map {[1] => \\"one\\", [2] => \\"two\\"}" +`; + +exports[`.toEqual() {pass: true} expect(Map {[1] => Map {[1] => "one"}, [2] => Map {[2] => "two"}}).not.toEqual(Map {[2] => Map {[2] => "two"}, [1] => Map {[1] => "one"}}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Map {[2] => Map {[2] => \\"two\\"}, [1] => Map {[1] => \\"one\\"}} +Received: Map {[1] => Map {[1] => \\"one\\"}, [2] => Map {[2] => \\"two\\"}}" +`; + +exports[`.toEqual() {pass: true} expect(Map {{"a": 1} => "one", {"b": 2} => "two"}).not.toEqual(Map {{"b": 2} => "two", {"a": 1} => "one"}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Map {{\\"b\\": 2} => \\"two\\", {\\"a\\": 1} => \\"one\\"} +Received: Map {{\\"a\\": 1} => \\"one\\", {\\"b\\": 2} => \\"two\\"}" +`; + +exports[`.toEqual() {pass: true} expect(Map {}).not.toEqual(Map {}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Map {} +Received: Map {}" +`; + +exports[`.toEqual() {pass: true} expect(Map {1 => "one", 2 => "two"}).not.toEqual(Map {1 => "one", 2 => "two"}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Map {1 => \\"one\\", 2 => \\"two\\"} +Received: Map {1 => \\"one\\", 2 => \\"two\\"}" +`; + +exports[`.toEqual() {pass: true} expect(Map {1 => "one", 2 => "two"}).not.toEqual(Map {2 => "two", 1 => "one"}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Map {2 => \\"two\\", 1 => \\"one\\"} +Received: Map {1 => \\"one\\", 2 => \\"two\\"}" +`; + +exports[`.toEqual() {pass: true} expect(Map {1 => ["one"], 2 => ["two"]}).not.toEqual(Map {2 => ["two"], 1 => ["one"]}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Map {2 => [\\"two\\"], 1 => [\\"one\\"]} +Received: Map {1 => [\\"one\\"], 2 => [\\"two\\"]}" +`; + +exports[`.toEqual() {pass: true} expect(NaN).not.toEqual(NaN) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: NaN +Received: NaN" +`; + +exports[`.toEqual() {pass: true} expect(Set {[1], [2], [3], [3]}).not.toEqual(Set {[3], [3], [2], [1]}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Set {[3], [3], [2], [1]} +Received: Set {[1], [2], [3], [3]}" +`; + +exports[`.toEqual() {pass: true} expect(Set {[1], [2]}).not.toEqual(Set {[2], [1]}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Set {[2], [1]} +Received: Set {[1], [2]}" +`; + +exports[`.toEqual() {pass: true} expect(Set {{"a": 1}, {"b": 2}}).not.toEqual(Set {{"b": 2}, {"a": 1}}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Set {{\\"b\\": 2}, {\\"a\\": 1}} +Received: Set {{\\"a\\": 1}, {\\"b\\": 2}}" +`; + +exports[`.toEqual() {pass: true} expect(Set {}).not.toEqual(Set {}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Set {} +Received: Set {}" +`; + +exports[`.toEqual() {pass: true} expect(Set {1, 2}).not.toEqual(Set {1, 2}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Set {1, 2} +Received: Set {1, 2}" +`; + +exports[`.toEqual() {pass: true} expect(Set {1, 2}).not.toEqual(Set {2, 1}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Set {2, 1} +Received: Set {1, 2}" +`; + +exports[`.toEqual() {pass: true} expect(Set {Set {[1]}, Set {[2]}}).not.toEqual(Set {Set {[2]}, Set {[1]}}) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Set {Set {[2]}, Set {[1]}} +Received: Set {Set {[1]}, Set {[2]}}" +`; + +exports[`.toEqual() {pass: true} expect(true).not.toEqual(Anything) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: Anything +Received: true" +`; + +exports[`.toEqual() {pass: true} expect(true).not.toEqual(true) 1`] = ` +"expect(received).not.toEqual(expected) + +Expected: true +Received: true" `; exports[`.toHaveLength {pass: false} expect("").toHaveLength(1) 1`] = ` diff --git a/packages/expect/src/__tests__/matchers.test.js b/packages/expect/src/__tests__/matchers.test.js index 953de2f2fcaf..68fd06b94082 100644 --- a/packages/expect/src/__tests__/matchers.test.js +++ b/packages/expect/src/__tests__/matchers.test.js @@ -346,6 +346,7 @@ describe('.toEqual()', () => { [0, -0], [0, Number.MIN_VALUE], // issues/7941 [Number.MIN_VALUE, 0], + [{a: 1}, {a: 2}], [{a: 5}, {b: 6}], ['banana', 'apple'], [null, undefined], @@ -432,6 +433,7 @@ describe('.toEqual()', () => { b, )})`, () => { expect(() => jestExpect(a).toEqual(b)).toThrowErrorMatchingSnapshot(); + jestExpect(a).not.toEqual(b); }); }); @@ -558,9 +560,10 @@ describe('.toEqual()', () => { }, ], ].forEach(([a, b]) => { - test(`{pass: false} expect(${stringify(a)}).not.toEqual(${stringify( + test(`{pass: true} expect(${stringify(a)}).not.toEqual(${stringify( b, )})`, () => { + jestExpect(a).toEqual(b); expect(() => jestExpect(a).not.toEqual(b)).toThrowErrorMatchingSnapshot(); }); }); @@ -581,16 +584,6 @@ describe('.toEqual()', () => { } }); - test('failure message matches the expected snapshot', () => { - expect(() => - jestExpect({a: 1}).toEqual({a: 2}), - ).toThrowErrorMatchingSnapshot(); - - expect(() => - jestExpect({a: 1}).not.toEqual({a: 1}), - ).toThrowErrorMatchingSnapshot(); - }); - test('symbol based keys in arrays are processed correctly', () => { const mySymbol = Symbol('test'); const actual1 = []; From fff97f8a8cfeb79442264baeb766ba9ddca7641f Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Mon, 8 Apr 2019 13:53:19 -0400 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec4926fe1557..f2498e5c93d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ ### Chore & Maintenance +- `[expect]` Fix label and add opposite assertion for toEqual tests ([#8288](https://github.com/facebook/jest/pull/8288)) + ### Performance - `[jest-runtime]` Fix module registry memory leak ([#8282](https://github.com/facebook/jest/pull/8282))