From 9c95516d37e64195bf59fe3a52bcf0caafc72793 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Fri, 9 Feb 2018 16:16:15 -0500 Subject: [PATCH 1/3] Improve description line when assertion fails: part 2 --- .../__snapshots__/matchers.test.js.snap | 1052 ++++++----------- packages/expect/src/matchers.js | 271 ++--- packages/jest-matcher-utils/src/index.js | 7 +- 3 files changed, 491 insertions(+), 839 deletions(-) diff --git a/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap b/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap index 7a1471e697b2..0fd386e121e9 100644 --- a/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap +++ b/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap @@ -203,10 +203,8 @@ Received: undefined" exports[`.toBe() does not crash on circular references 1`] = ` "expect(received).toBe(expected) // Object.is equality -Expected value to be: - {} -Received: - {\\"circular\\": [Circular]} +Expected: {} +Received: {\\"circular\\": [Circular]} Difference: @@ -220,95 +218,75 @@ Difference: `; exports[`.toBe() fails for '"a"' with '.not' 1`] = ` -"expect(received).not.toBe(expected) // Object.is equality +"expect(received).not.toBe(expected) // Object.is equality -Expected value to not be: - \\"a\\" -Received: - \\"a\\"" +Expected: \\"a\\" +Received: \\"a\\"" `; exports[`.toBe() fails for '[]' with '.not' 1`] = ` -"expect(received).not.toBe(expected) // Object.is equality +"expect(received).not.toBe(expected) // Object.is equality -Expected value to not be: - [] -Received: - []" +Expected: [] +Received: []" `; exports[`.toBe() fails for '{}' with '.not' 1`] = ` -"expect(received).not.toBe(expected) // Object.is equality +"expect(received).not.toBe(expected) // Object.is equality -Expected value to not be: - {} -Received: - {}" +Expected: {} +Received: {}" `; exports[`.toBe() fails for '1' with '.not' 1`] = ` -"expect(received).not.toBe(expected) // Object.is equality +"expect(received).not.toBe(expected) // Object.is equality -Expected value to not be: - 1 -Received: - 1" +Expected: 1 +Received: 1" `; exports[`.toBe() fails for 'false' with '.not' 1`] = ` -"expect(received).not.toBe(expected) // Object.is equality +"expect(received).not.toBe(expected) // Object.is equality -Expected value to not be: - false -Received: - false" +Expected: false +Received: false" `; exports[`.toBe() fails for 'null' with '.not' 1`] = ` -"expect(received).not.toBe(expected) // Object.is equality +"expect(received).not.toBe(expected) // Object.is equality -Expected value to not be: - null -Received: - null" +Expected: null +Received: null" `; exports[`.toBe() fails for 'undefined' with '.not' 1`] = ` -"expect(received).not.toBe(expected) // Object.is equality +"expect(received).not.toBe(expected) // Object.is equality -Expected value to not be: - undefined -Received: - undefined" +Expected: undefined +Received: undefined" `; exports[`.toBe() fails for: "abc" and "cde" 1`] = ` "expect(received).toBe(expected) // Object.is equality -Expected value to be: - \\"cde\\" -Received: - \\"abc\\"" +Expected: \\"cde\\" +Received: \\"abc\\"" `; exports[`.toBe() fails for: "with trailing space" and "without trailing space" 1`] = ` "expect(received).toBe(expected) // Object.is equality -Expected value to be: - \\"without trailing space\\" -Received: - \\"with +Expected: \\"without trailing space\\" +Received: \\"with trailing space\\"" `; exports[`.toBe() fails for: [] and [] 1`] = ` "expect(received).toBe(expected) // Object.is equality -Expected value to be: - [] -Received: - [] +Expected: [] +Received: [] Difference: @@ -318,10 +296,8 @@ Difference: exports[`.toBe() fails for: {"a": 1} and {"a": 1} 1`] = ` "expect(received).toBe(expected) // Object.is equality -Expected value to be: - {\\"a\\": 1} -Received: - {\\"a\\": 1} +Expected: {\\"a\\": 1} +Received: {\\"a\\": 1} Difference: @@ -331,10 +307,8 @@ Difference: exports[`.toBe() fails for: {"a": 1} and {"a": 5} 1`] = ` "expect(received).toBe(expected) // Object.is equality -Expected value to be: - {\\"a\\": 5} -Received: - {\\"a\\": 1} +Expected: {\\"a\\": 5} +Received: {\\"a\\": 1} Difference: @@ -350,10 +324,8 @@ Difference: exports[`.toBe() fails for: {} and {} 1`] = ` "expect(received).toBe(expected) // Object.is equality -Expected value to be: - {} -Received: - {} +Expected: {} +Received: {} Difference: @@ -363,10 +335,8 @@ Difference: exports[`.toBe() fails for: -0 and 0 1`] = ` "expect(received).toBe(expected) // Object.is equality -Expected value to be: - 0 -Received: - -0 +Expected: 0 +Received: -0 Difference: @@ -376,19 +346,15 @@ Difference: exports[`.toBe() fails for: 1 and 2 1`] = ` "expect(received).toBe(expected) // Object.is equality -Expected value to be: - 2 -Received: - 1" +Expected: 2 +Received: 1" `; exports[`.toBe() fails for: null and undefined 1`] = ` "expect(received).toBe(expected) // Object.is equality -Expected value to be: - undefined -Received: - null +Expected: undefined +Received: null Difference: @@ -398,1322 +364,1078 @@ Difference: exports[`.toBe() fails for: true and false 1`] = ` "expect(received).toBe(expected) // Object.is equality -Expected value to be: - false -Received: - true" +Expected: false +Received: true" `; exports[`.toBeCloseTo() {pass: true} expect(0)toBeCloseTo( 0) 1`] = ` -"expect(received).not.toBeCloseTo(expected) +"expect(received).not.toBeCloseTo(expected) -Expected value not to be close to (with 2-digit precision): - 0 -Received: - 0" +Precision: 2-digit +Expected: 0 +Received: 0" `; exports[`.toBeCloseTo() {pass: true} expect(0)toBeCloseTo( 0.001) 1`] = ` -"expect(received).not.toBeCloseTo(expected) +"expect(received).not.toBeCloseTo(expected) -Expected value not to be close to (with 2-digit precision): - 0.001 -Received: - 0" +Precision: 2-digit +Expected: 0.001 +Received: 0" `; exports[`.toBeCloseTo() {pass: true} expect(1.23)toBeCloseTo( 1.225) 1`] = ` -"expect(received).not.toBeCloseTo(expected) +"expect(received).not.toBeCloseTo(expected) -Expected value not to be close to (with 2-digit precision): - 1.225 -Received: - 1.23" +Precision: 2-digit +Expected: 1.225 +Received: 1.23" `; exports[`.toBeCloseTo() {pass: true} expect(1.23)toBeCloseTo( 1.226) 1`] = ` -"expect(received).not.toBeCloseTo(expected) +"expect(received).not.toBeCloseTo(expected) -Expected value not to be close to (with 2-digit precision): - 1.226 -Received: - 1.23" +Precision: 2-digit +Expected: 1.226 +Received: 1.23" `; exports[`.toBeCloseTo() {pass: true} expect(1.23)toBeCloseTo( 1.229) 1`] = ` -"expect(received).not.toBeCloseTo(expected) +"expect(received).not.toBeCloseTo(expected) -Expected value not to be close to (with 2-digit precision): - 1.229 -Received: - 1.23" +Precision: 2-digit +Expected: 1.229 +Received: 1.23" `; exports[`.toBeCloseTo() {pass: true} expect(1.23)toBeCloseTo( 1.234) 1`] = ` -"expect(received).not.toBeCloseTo(expected) +"expect(received).not.toBeCloseTo(expected) -Expected value not to be close to (with 2-digit precision): - 1.234 -Received: - 1.23" +Precision: 2-digit +Expected: 1.234 +Received: 1.23" `; exports[`.toBeCloseTo() accepts an optional precision argument: [0, 0.000004, 5] 1`] = ` -"expect(received).not.toBeCloseTo(expected, precision) +"expect(received).not.toBeCloseTo(expected, precision) -Expected value not to be close to (with 5-digit precision): - 0.000004 -Received: - 0" +Precision: 5-digit +Expected: 0.000004 +Received: 0" `; exports[`.toBeCloseTo() accepts an optional precision argument: [0, 0.0001, 3] 1`] = ` -"expect(received).not.toBeCloseTo(expected, precision) +"expect(received).not.toBeCloseTo(expected, precision) -Expected value not to be close to (with 3-digit precision): - 0.0001 -Received: - 0" +Precision: 3-digit +Expected: 0.0001 +Received: 0" `; exports[`.toBeCloseTo() accepts an optional precision argument: [0, 0.1, 0] 1`] = ` -"expect(received).not.toBeCloseTo(expected, precision) +"expect(received).not.toBeCloseTo(expected, precision) -Expected value not to be close to (with 0-digit precision): - 0.1 -Received: - 0" +Precision: 0-digit +Expected: 0.1 +Received: 0" `; exports[`.toBeCloseTo() throws: [0, 0.01] 1`] = ` "expect(received).toBeCloseTo(expected) -Expected value to be close to (with 2-digit precision): - 0.01 -Received: - 0" +Precision: 2-digit +Expected: 0.01 +Received: 0" `; exports[`.toBeCloseTo() throws: [1, 1.23] 1`] = ` "expect(received).toBeCloseTo(expected) -Expected value to be close to (with 2-digit precision): - 1.23 -Received: - 1" +Precision: 2-digit +Expected: 1.23 +Received: 1" `; exports[`.toBeCloseTo() throws: [1.23, 1.2249999] 1`] = ` "expect(received).toBeCloseTo(expected) -Expected value to be close to (with 2-digit precision): - 1.2249999 -Received: - 1.23" +Precision: 2-digit +Expected: 1.2249999 +Received: 1.23" `; exports[`.toBeDefined(), .toBeUndefined() '"a"' is defined 1`] = ` -"expect(received).not.toBeDefined() +"expect(received).not.toBeDefined() -Expected value not to be defined, instead received - \\"a\\"" +Received: \\"a\\"" `; exports[`.toBeDefined(), .toBeUndefined() '"a"' is defined 2`] = ` "expect(received).toBeUndefined() -Expected value to be undefined, instead received - \\"a\\"" +Received: \\"a\\"" `; exports[`.toBeDefined(), .toBeUndefined() '[]' is defined 1`] = ` -"expect(received).not.toBeDefined() +"expect(received).not.toBeDefined() -Expected value not to be defined, instead received - []" +Received: []" `; exports[`.toBeDefined(), .toBeUndefined() '[]' is defined 2`] = ` "expect(received).toBeUndefined() -Expected value to be undefined, instead received - []" +Received: []" `; exports[`.toBeDefined(), .toBeUndefined() '[Function anonymous]' is defined 1`] = ` -"expect(received).not.toBeDefined() +"expect(received).not.toBeDefined() -Expected value not to be defined, instead received - [Function anonymous]" +Received: [Function anonymous]" `; exports[`.toBeDefined(), .toBeUndefined() '[Function anonymous]' is defined 2`] = ` "expect(received).toBeUndefined() -Expected value to be undefined, instead received - [Function anonymous]" +Received: [Function anonymous]" `; exports[`.toBeDefined(), .toBeUndefined() '{}' is defined 1`] = ` -"expect(received).not.toBeDefined() +"expect(received).not.toBeDefined() -Expected value not to be defined, instead received - {}" +Received: {}" `; exports[`.toBeDefined(), .toBeUndefined() '{}' is defined 2`] = ` "expect(received).toBeUndefined() -Expected value to be undefined, instead received - {}" +Received: {}" `; exports[`.toBeDefined(), .toBeUndefined() '0.5' is defined 1`] = ` -"expect(received).not.toBeDefined() +"expect(received).not.toBeDefined() -Expected value not to be defined, instead received - 0.5" +Received: 0.5" `; exports[`.toBeDefined(), .toBeUndefined() '0.5' is defined 2`] = ` "expect(received).toBeUndefined() -Expected value to be undefined, instead received - 0.5" +Received: 0.5" `; exports[`.toBeDefined(), .toBeUndefined() '1' is defined 1`] = ` -"expect(received).not.toBeDefined() +"expect(received).not.toBeDefined() -Expected value not to be defined, instead received - 1" +Received: 1" `; exports[`.toBeDefined(), .toBeUndefined() '1' is defined 2`] = ` "expect(received).toBeUndefined() -Expected value to be undefined, instead received - 1" +Received: 1" `; exports[`.toBeDefined(), .toBeUndefined() 'Infinity' is defined 1`] = ` -"expect(received).not.toBeDefined() +"expect(received).not.toBeDefined() -Expected value not to be defined, instead received - Infinity" +Received: Infinity" `; exports[`.toBeDefined(), .toBeUndefined() 'Infinity' is defined 2`] = ` "expect(received).toBeUndefined() -Expected value to be undefined, instead received - Infinity" +Received: Infinity" `; exports[`.toBeDefined(), .toBeUndefined() 'Map {}' is defined 1`] = ` -"expect(received).not.toBeDefined() +"expect(received).not.toBeDefined() -Expected value not to be defined, instead received - Map {}" +Received: Map {}" `; exports[`.toBeDefined(), .toBeUndefined() 'Map {}' is defined 2`] = ` "expect(received).toBeUndefined() -Expected value to be undefined, instead received - Map {}" +Received: Map {}" `; exports[`.toBeDefined(), .toBeUndefined() 'true' is defined 1`] = ` -"expect(received).not.toBeDefined() +"expect(received).not.toBeDefined() -Expected value not to be defined, instead received - true" +Received: true" `; exports[`.toBeDefined(), .toBeUndefined() 'true' is defined 2`] = ` "expect(received).toBeUndefined() -Expected value to be undefined, instead received - true" +Received: true" `; exports[`.toBeDefined(), .toBeUndefined() undefined is undefined 1`] = ` "expect(received).toBeDefined() -Expected value to be defined, instead received - undefined" +Received: undefined" `; exports[`.toBeDefined(), .toBeUndefined() undefined is undefined 2`] = ` -"expect(received).not.toBeUndefined() +"expect(received).not.toBeUndefined() -Expected value not to be undefined, instead received - undefined" +Received: undefined" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() equal numbers: [-Infinity, -Infinity] 1`] = ` -"expect(received).not.toBeGreaterThanOrEqual(expected) +"expect(received).not.toBeGreaterThanOrEqual(expected) -Expected value not to be greater than or equal: - -Infinity -Received: - -Infinity" +Expected: -Infinity +Received: -Infinity" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() equal numbers: [-Infinity, -Infinity] 2`] = ` -"expect(received).not.toBeLessThanOrEqual(expected) +"expect(received).not.toBeLessThanOrEqual(expected) -Expected value not to be less than or equal: - -Infinity -Received: - -Infinity" +Expected: -Infinity +Received: -Infinity" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() equal numbers: [1, 1] 1`] = ` -"expect(received).not.toBeGreaterThanOrEqual(expected) +"expect(received).not.toBeGreaterThanOrEqual(expected) -Expected value not to be greater than or equal: - 1 -Received: - 1" +Expected: 1 +Received: 1" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() equal numbers: [1, 1] 2`] = ` -"expect(received).not.toBeLessThanOrEqual(expected) +"expect(received).not.toBeLessThanOrEqual(expected) -Expected value not to be less than or equal: - 1 -Received: - 1" +Expected: 1 +Received: 1" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() equal numbers: [1.7976931348623157e+308, 1.7976931348623157e+308] 1`] = ` -"expect(received).not.toBeGreaterThanOrEqual(expected) +"expect(received).not.toBeGreaterThanOrEqual(expected) -Expected value not to be greater than or equal: - 1.7976931348623157e+308 -Received: - 1.7976931348623157e+308" +Expected: 1.7976931348623157e+308 +Received: 1.7976931348623157e+308" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() equal numbers: [1.7976931348623157e+308, 1.7976931348623157e+308] 2`] = ` -"expect(received).not.toBeLessThanOrEqual(expected) +"expect(received).not.toBeLessThanOrEqual(expected) -Expected value not to be less than or equal: - 1.7976931348623157e+308 -Received: - 1.7976931348623157e+308" +Expected: 1.7976931348623157e+308 +Received: 1.7976931348623157e+308" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() equal numbers: [5e-324, 5e-324] 1`] = ` -"expect(received).not.toBeGreaterThanOrEqual(expected) +"expect(received).not.toBeGreaterThanOrEqual(expected) -Expected value not to be greater than or equal: - 5e-324 -Received: - 5e-324" +Expected: 5e-324 +Received: 5e-324" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() equal numbers: [5e-324, 5e-324] 2`] = ` -"expect(received).not.toBeLessThanOrEqual(expected) +"expect(received).not.toBeLessThanOrEqual(expected) -Expected value not to be less than or equal: - 5e-324 -Received: - 5e-324" +Expected: 5e-324 +Received: 5e-324" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() equal numbers: [Infinity, Infinity] 1`] = ` -"expect(received).not.toBeGreaterThanOrEqual(expected) +"expect(received).not.toBeGreaterThanOrEqual(expected) -Expected value not to be greater than or equal: - Infinity -Received: - Infinity" +Expected: Infinity +Received: Infinity" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() equal numbers: [Infinity, Infinity] 2`] = ` -"expect(received).not.toBeLessThanOrEqual(expected) +"expect(received).not.toBeLessThanOrEqual(expected) -Expected value not to be less than or equal: - Infinity -Received: - Infinity" +Expected: Infinity +Received: Infinity" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [-Infinity, Infinity] 1`] = ` "expect(received).toBeGreaterThan(expected) -Expected value to be greater than: - Infinity -Received: - -Infinity" +Expected: Infinity +Received: -Infinity" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [-Infinity, Infinity] 2`] = ` -"expect(received).not.toBeLessThan(expected) +"expect(received).not.toBeLessThan(expected) -Expected value not to be less than: - Infinity -Received: - -Infinity" +Expected: Infinity +Received: -Infinity" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [-Infinity, Infinity] 3`] = ` -"expect(received).not.toBeGreaterThan(expected) +"expect(received).not.toBeGreaterThan(expected) -Expected value not to be greater than: - -Infinity -Received: - Infinity" +Expected: -Infinity +Received: Infinity" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [-Infinity, Infinity] 4`] = ` "expect(received).toBeLessThan(expected) -Expected value to be less than: - -Infinity -Received: - Infinity" +Expected: -Infinity +Received: Infinity" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [-Infinity, Infinity] 5`] = ` "expect(received).toBeGreaterThanOrEqual(expected) -Expected value to be greater than or equal: - Infinity -Received: - -Infinity" +Expected: Infinity +Received: -Infinity" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [-Infinity, Infinity] 6`] = ` -"expect(received).not.toBeLessThanOrEqual(expected) +"expect(received).not.toBeLessThanOrEqual(expected) -Expected value not to be less than or equal: - Infinity -Received: - -Infinity" +Expected: Infinity +Received: -Infinity" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [-Infinity, Infinity] 7`] = ` -"expect(received).not.toBeGreaterThanOrEqual(expected) +"expect(received).not.toBeGreaterThanOrEqual(expected) -Expected value not to be greater than or equal: - -Infinity -Received: - Infinity" +Expected: -Infinity +Received: Infinity" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [-Infinity, Infinity] 8`] = ` "expect(received).toBeLessThanOrEqual(expected) -Expected value to be less than or equal: - -Infinity -Received: - Infinity" +Expected: -Infinity +Received: Infinity" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [0.1, 0.2] 1`] = ` "expect(received).toBeGreaterThan(expected) -Expected value to be greater than: - 0.2 -Received: - 0.1" +Expected: 0.2 +Received: 0.1" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [0.1, 0.2] 2`] = ` -"expect(received).not.toBeLessThan(expected) +"expect(received).not.toBeLessThan(expected) -Expected value not to be less than: - 0.2 -Received: - 0.1" +Expected: 0.2 +Received: 0.1" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [0.1, 0.2] 3`] = ` -"expect(received).not.toBeGreaterThan(expected) +"expect(received).not.toBeGreaterThan(expected) -Expected value not to be greater than: - 0.1 -Received: - 0.2" +Expected: 0.1 +Received: 0.2" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [0.1, 0.2] 4`] = ` "expect(received).toBeLessThan(expected) -Expected value to be less than: - 0.1 -Received: - 0.2" +Expected: 0.1 +Received: 0.2" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [0.1, 0.2] 5`] = ` "expect(received).toBeGreaterThanOrEqual(expected) -Expected value to be greater than or equal: - 0.2 -Received: - 0.1" +Expected: 0.2 +Received: 0.1" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [0.1, 0.2] 6`] = ` -"expect(received).not.toBeLessThanOrEqual(expected) +"expect(received).not.toBeLessThanOrEqual(expected) -Expected value not to be less than or equal: - 0.2 -Received: - 0.1" +Expected: 0.2 +Received: 0.1" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [0.1, 0.2] 7`] = ` -"expect(received).not.toBeGreaterThanOrEqual(expected) +"expect(received).not.toBeGreaterThanOrEqual(expected) -Expected value not to be greater than or equal: - 0.1 -Received: - 0.2" +Expected: 0.1 +Received: 0.2" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [0.1, 0.2] 8`] = ` "expect(received).toBeLessThanOrEqual(expected) -Expected value to be less than or equal: - 0.1 -Received: - 0.2" +Expected: 0.1 +Received: 0.2" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [1, 2] 1`] = ` "expect(received).toBeGreaterThan(expected) -Expected value to be greater than: - 2 -Received: - 1" +Expected: 2 +Received: 1" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [1, 2] 2`] = ` -"expect(received).not.toBeLessThan(expected) +"expect(received).not.toBeLessThan(expected) -Expected value not to be less than: - 2 -Received: - 1" +Expected: 2 +Received: 1" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [1, 2] 3`] = ` -"expect(received).not.toBeGreaterThan(expected) +"expect(received).not.toBeGreaterThan(expected) -Expected value not to be greater than: - 1 -Received: - 2" +Expected: 1 +Received: 2" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [1, 2] 4`] = ` "expect(received).toBeLessThan(expected) -Expected value to be less than: - 1 -Received: - 2" +Expected: 1 +Received: 2" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [1, 2] 5`] = ` "expect(received).toBeGreaterThanOrEqual(expected) -Expected value to be greater than or equal: - 2 -Received: - 1" +Expected: 2 +Received: 1" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [1, 2] 6`] = ` -"expect(received).not.toBeLessThanOrEqual(expected) +"expect(received).not.toBeLessThanOrEqual(expected) -Expected value not to be less than or equal: - 2 -Received: - 1" +Expected: 2 +Received: 1" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [1, 2] 7`] = ` -"expect(received).not.toBeGreaterThanOrEqual(expected) +"expect(received).not.toBeGreaterThanOrEqual(expected) -Expected value not to be greater than or equal: - 1 -Received: - 2" +Expected: 1 +Received: 2" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [1, 2] 8`] = ` "expect(received).toBeLessThanOrEqual(expected) -Expected value to be less than or equal: - 1 -Received: - 2" +Expected: 1 +Received: 2" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [3, 7] 1`] = ` "expect(received).toBeGreaterThan(expected) -Expected value to be greater than: - 7 -Received: - 3" +Expected: 7 +Received: 3" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [3, 7] 2`] = ` -"expect(received).not.toBeLessThan(expected) +"expect(received).not.toBeLessThan(expected) -Expected value not to be less than: - 7 -Received: - 3" +Expected: 7 +Received: 3" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [3, 7] 3`] = ` -"expect(received).not.toBeGreaterThan(expected) +"expect(received).not.toBeGreaterThan(expected) -Expected value not to be greater than: - 3 -Received: - 7" +Expected: 3 +Received: 7" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [3, 7] 4`] = ` "expect(received).toBeLessThan(expected) -Expected value to be less than: - 3 -Received: - 7" +Expected: 3 +Received: 7" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [3, 7] 5`] = ` "expect(received).toBeGreaterThanOrEqual(expected) -Expected value to be greater than or equal: - 7 -Received: - 3" +Expected: 7 +Received: 3" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [3, 7] 6`] = ` -"expect(received).not.toBeLessThanOrEqual(expected) +"expect(received).not.toBeLessThanOrEqual(expected) -Expected value not to be less than or equal: - 7 -Received: - 3" +Expected: 7 +Received: 3" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [3, 7] 7`] = ` -"expect(received).not.toBeGreaterThanOrEqual(expected) +"expect(received).not.toBeGreaterThanOrEqual(expected) -Expected value not to be greater than or equal: - 3 -Received: - 7" +Expected: 3 +Received: 7" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [3, 7] 8`] = ` "expect(received).toBeLessThanOrEqual(expected) -Expected value to be less than or equal: - 3 -Received: - 7" +Expected: 3 +Received: 7" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [5e-324, 1.7976931348623157e+308] 1`] = ` "expect(received).toBeGreaterThan(expected) -Expected value to be greater than: - 1.7976931348623157e+308 -Received: - 5e-324" +Expected: 1.7976931348623157e+308 +Received: 5e-324" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [5e-324, 1.7976931348623157e+308] 2`] = ` -"expect(received).not.toBeLessThan(expected) +"expect(received).not.toBeLessThan(expected) -Expected value not to be less than: - 1.7976931348623157e+308 -Received: - 5e-324" +Expected: 1.7976931348623157e+308 +Received: 5e-324" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [5e-324, 1.7976931348623157e+308] 3`] = ` -"expect(received).not.toBeGreaterThan(expected) +"expect(received).not.toBeGreaterThan(expected) -Expected value not to be greater than: - 5e-324 -Received: - 1.7976931348623157e+308" +Expected: 5e-324 +Received: 1.7976931348623157e+308" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [5e-324, 1.7976931348623157e+308] 4`] = ` "expect(received).toBeLessThan(expected) -Expected value to be less than: - 5e-324 -Received: - 1.7976931348623157e+308" +Expected: 5e-324 +Received: 1.7976931348623157e+308" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [5e-324, 1.7976931348623157e+308] 5`] = ` "expect(received).toBeGreaterThanOrEqual(expected) -Expected value to be greater than or equal: - 1.7976931348623157e+308 -Received: - 5e-324" +Expected: 1.7976931348623157e+308 +Received: 5e-324" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [5e-324, 1.7976931348623157e+308] 6`] = ` -"expect(received).not.toBeLessThanOrEqual(expected) +"expect(received).not.toBeLessThanOrEqual(expected) -Expected value not to be less than or equal: - 1.7976931348623157e+308 -Received: - 5e-324" +Expected: 1.7976931348623157e+308 +Received: 5e-324" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [5e-324, 1.7976931348623157e+308] 7`] = ` -"expect(received).not.toBeGreaterThanOrEqual(expected) +"expect(received).not.toBeGreaterThanOrEqual(expected) -Expected value not to be greater than or equal: - 5e-324 -Received: - 1.7976931348623157e+308" +Expected: 5e-324 +Received: 1.7976931348623157e+308" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [5e-324, 1.7976931348623157e+308] 8`] = ` "expect(received).toBeLessThanOrEqual(expected) -Expected value to be less than or equal: - 5e-324 -Received: - 1.7976931348623157e+308" +Expected: 5e-324 +Received: 1.7976931348623157e+308" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [9, 18] 1`] = ` "expect(received).toBeGreaterThan(expected) -Expected value to be greater than: - 18 -Received: - 9" +Expected: 18 +Received: 9" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [9, 18] 2`] = ` -"expect(received).not.toBeLessThan(expected) +"expect(received).not.toBeLessThan(expected) -Expected value not to be less than: - 18 -Received: - 9" +Expected: 18 +Received: 9" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [9, 18] 3`] = ` -"expect(received).not.toBeGreaterThan(expected) +"expect(received).not.toBeGreaterThan(expected) -Expected value not to be greater than: - 9 -Received: - 18" +Expected: 9 +Received: 18" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [9, 18] 4`] = ` "expect(received).toBeLessThan(expected) -Expected value to be less than: - 9 -Received: - 18" +Expected: 9 +Received: 18" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [9, 18] 5`] = ` "expect(received).toBeGreaterThanOrEqual(expected) -Expected value to be greater than or equal: - 18 -Received: - 9" +Expected: 18 +Received: 9" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [9, 18] 6`] = ` -"expect(received).not.toBeLessThanOrEqual(expected) +"expect(received).not.toBeLessThanOrEqual(expected) -Expected value not to be less than or equal: - 18 -Received: - 9" +Expected: 18 +Received: 9" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [9, 18] 7`] = ` -"expect(received).not.toBeGreaterThanOrEqual(expected) +"expect(received).not.toBeGreaterThanOrEqual(expected) -Expected value not to be greater than or equal: - 9 -Received: - 18" +Expected: 9 +Received: 18" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [9, 18] 8`] = ` "expect(received).toBeLessThanOrEqual(expected) -Expected value to be less than or equal: - 9 -Received: - 18" +Expected: 9 +Received: 18" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [17, 34] 1`] = ` "expect(received).toBeGreaterThan(expected) -Expected value to be greater than: - 34 -Received: - 17" +Expected: 34 +Received: 17" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [17, 34] 2`] = ` -"expect(received).not.toBeLessThan(expected) +"expect(received).not.toBeLessThan(expected) -Expected value not to be less than: - 34 -Received: - 17" +Expected: 34 +Received: 17" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [17, 34] 3`] = ` -"expect(received).not.toBeGreaterThan(expected) +"expect(received).not.toBeGreaterThan(expected) -Expected value not to be greater than: - 17 -Received: - 34" +Expected: 17 +Received: 34" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [17, 34] 4`] = ` "expect(received).toBeLessThan(expected) -Expected value to be less than: - 17 -Received: - 34" +Expected: 17 +Received: 34" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [17, 34] 5`] = ` "expect(received).toBeGreaterThanOrEqual(expected) -Expected value to be greater than or equal: - 34 -Received: - 17" +Expected: 34 +Received: 17" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [17, 34] 6`] = ` -"expect(received).not.toBeLessThanOrEqual(expected) +"expect(received).not.toBeLessThanOrEqual(expected) -Expected value not to be less than or equal: - 34 -Received: - 17" +Expected: 34 +Received: 17" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [17, 34] 7`] = ` -"expect(received).not.toBeGreaterThanOrEqual(expected) +"expect(received).not.toBeGreaterThanOrEqual(expected) -Expected value not to be greater than or equal: - 17 -Received: - 34" +Expected: 17 +Received: 34" `; exports[`.toBeGreaterThan(), .toBeLessThan(), .toBeGreaterThanOrEqual(), .toBeLessThanOrEqual() throws: [17, 34] 8`] = ` "expect(received).toBeLessThanOrEqual(expected) -Expected value to be less than or equal: - 17 -Received: - 34" +Expected: 17 +Received: 34" `; exports[`.toBeInstanceOf() failing "a" and [Function String] 1`] = ` "expect(value).toBeInstanceOf(constructor) -Expected value to be an instance of: - \\"String\\" -Received: - \\"a\\" -Constructor: - \\"String\\"" +Expected constructor: String +Received constructor: String +Received value: \\"a\\"" `; exports[`.toBeInstanceOf() failing {} and [Function A] 1`] = ` "expect(value).toBeInstanceOf(constructor) -Expected value to be an instance of: - \\"A\\" -Received: - {} -Constructor: - undefined" +Expected constructor: A +Received constructor: undefined +Received value: {}" `; exports[`.toBeInstanceOf() failing {} and [Function B] 1`] = ` "expect(value).toBeInstanceOf(constructor) -Expected value to be an instance of: - \\"B\\" -Received: - {} -Constructor: - \\"A\\"" +Expected constructor: B +Received constructor: A +Received value: {}" `; exports[`.toBeInstanceOf() failing 1 and [Function Number] 1`] = ` "expect(value).toBeInstanceOf(constructor) -Expected value to be an instance of: - \\"Number\\" -Received: - 1 -Constructor: - \\"Number\\"" +Expected constructor: Number +Received constructor: Number +Received value: 1" `; exports[`.toBeInstanceOf() failing true and [Function Boolean] 1`] = ` "expect(value).toBeInstanceOf(constructor) -Expected value to be an instance of: - \\"Boolean\\" -Received: - true -Constructor: - \\"Boolean\\"" +Expected constructor: Boolean +Received constructor: Boolean +Received value: true" `; exports[`.toBeInstanceOf() passing [] and [Function Array] 1`] = ` -"expect(value).not.toBeInstanceOf(constructor) +"expect(value).not.toBeInstanceOf(constructor) -Expected value not to be an instance of: - \\"Array\\" -Received: - [] -" +Expected constructor: Array +Received value: []" `; exports[`.toBeInstanceOf() passing {} and [Function A] 1`] = ` -"expect(value).not.toBeInstanceOf(constructor) +"expect(value).not.toBeInstanceOf(constructor) -Expected value not to be an instance of: - \\"A\\" -Received: - {} -" +Expected constructor: A +Received value: {}" `; exports[`.toBeInstanceOf() passing Map {} and [Function Map] 1`] = ` -"expect(value).not.toBeInstanceOf(constructor) +"expect(value).not.toBeInstanceOf(constructor) -Expected value not to be an instance of: - \\"Map\\" -Received: - Map {} -" +Expected constructor: Map +Received value: Map {}" `; exports[`.toBeInstanceOf() throws if constructor is not a function 1`] = ` -"expect(value)[.not].toBeInstanceOf(constructor) +"expect(value).toBeInstanceOf(constructor) Expected constructor to be a function. Instead got: \\"number\\"" `; exports[`.toBeNaN() {pass: true} expect(NaN).toBeNaN() 1`] = ` -"expect(received).not.toBeNaN() +"expect(received).not.toBeNaN() -Expected value not to be NaN, instead received - NaN" +Received: NaN" `; exports[`.toBeNaN() {pass: true} expect(NaN).toBeNaN() 2`] = ` -"expect(received).not.toBeNaN() +"expect(received).not.toBeNaN() -Expected value not to be NaN, instead received - NaN" +Received: NaN" `; exports[`.toBeNaN() {pass: true} expect(NaN).toBeNaN() 3`] = ` -"expect(received).not.toBeNaN() +"expect(received).not.toBeNaN() -Expected value not to be NaN, instead received - NaN" +Received: NaN" `; exports[`.toBeNaN() {pass: true} expect(NaN).toBeNaN() 4`] = ` -"expect(received).not.toBeNaN() +"expect(received).not.toBeNaN() -Expected value not to be NaN, instead received - NaN" +Received: NaN" `; exports[`.toBeNaN() throws 1`] = ` "expect(received).toBeNaN() -Expected value to be NaN, instead received - 1" +Received: 1" `; exports[`.toBeNaN() throws 2`] = ` "expect(received).toBeNaN() -Expected value to be NaN, instead received - \\"\\"" +Received: \\"\\"" `; exports[`.toBeNaN() throws 3`] = ` "expect(received).toBeNaN() -Expected value to be NaN, instead received - null" +Received: null" `; exports[`.toBeNaN() throws 4`] = ` "expect(received).toBeNaN() -Expected value to be NaN, instead received - undefined" +Received: undefined" `; exports[`.toBeNaN() throws 5`] = ` "expect(received).toBeNaN() -Expected value to be NaN, instead received - {}" +Received: {}" `; exports[`.toBeNaN() throws 6`] = ` "expect(received).toBeNaN() -Expected value to be NaN, instead received - []" +Received: []" `; exports[`.toBeNaN() throws 7`] = ` "expect(received).toBeNaN() -Expected value to be NaN, instead received - 0.2" +Received: 0.2" `; exports[`.toBeNaN() throws 8`] = ` "expect(received).toBeNaN() -Expected value to be NaN, instead received - 0" +Received: 0" `; exports[`.toBeNaN() throws 9`] = ` "expect(received).toBeNaN() -Expected value to be NaN, instead received - Infinity" +Received: Infinity" `; exports[`.toBeNaN() throws 10`] = ` "expect(received).toBeNaN() -Expected value to be NaN, instead received - -Infinity" +Received: -Infinity" `; exports[`.toBeNull() fails for '"a"' with .not 1`] = ` "expect(received).toBeNull() -Expected value to be null, instead received - \\"a\\"" +Received: \\"a\\"" `; exports[`.toBeNull() fails for '[]' with .not 1`] = ` "expect(received).toBeNull() -Expected value to be null, instead received - []" +Received: []" `; exports[`.toBeNull() fails for '[Function anonymous]' with .not 1`] = ` "expect(received).toBeNull() -Expected value to be null, instead received - [Function anonymous]" +Received: [Function anonymous]" `; exports[`.toBeNull() fails for '{}' with .not 1`] = ` "expect(received).toBeNull() -Expected value to be null, instead received - {}" +Received: {}" `; exports[`.toBeNull() fails for '0.5' with .not 1`] = ` "expect(received).toBeNull() -Expected value to be null, instead received - 0.5" +Received: 0.5" `; exports[`.toBeNull() fails for '1' with .not 1`] = ` "expect(received).toBeNull() -Expected value to be null, instead received - 1" +Received: 1" `; exports[`.toBeNull() fails for 'Infinity' with .not 1`] = ` "expect(received).toBeNull() -Expected value to be null, instead received - Infinity" +Received: Infinity" `; exports[`.toBeNull() fails for 'Map {}' with .not 1`] = ` "expect(received).toBeNull() -Expected value to be null, instead received - Map {}" +Received: Map {}" `; exports[`.toBeNull() fails for 'true' with .not 1`] = ` "expect(received).toBeNull() -Expected value to be null, instead received - true" +Received: true" `; exports[`.toBeNull() pass for null 1`] = ` -"expect(received).not.toBeNull() +"expect(received).not.toBeNull() -Expected value not to be null, instead received - null" +Received: null" `; exports[`.toBeTruthy(), .toBeFalsy() '""' is falsy 1`] = ` "expect(received).toBeTruthy() -Expected value to be truthy, instead received - \\"\\"" +Received: \\"\\"" `; exports[`.toBeTruthy(), .toBeFalsy() '""' is falsy 2`] = ` -"expect(received).not.toBeFalsy() +"expect(received).not.toBeFalsy() -Expected value not to be falsy, instead received - \\"\\"" +Received: \\"\\"" `; exports[`.toBeTruthy(), .toBeFalsy() '"a"' is truthy 1`] = ` -"expect(received).not.toBeTruthy() +"expect(received).not.toBeTruthy() -Expected value not to be truthy, instead received - \\"a\\"" +Received: \\"a\\"" `; exports[`.toBeTruthy(), .toBeFalsy() '"a"' is truthy 2`] = ` "expect(received).toBeFalsy() -Expected value to be falsy, instead received - \\"a\\"" +Received: \\"a\\"" `; exports[`.toBeTruthy(), .toBeFalsy() '[]' is truthy 1`] = ` -"expect(received).not.toBeTruthy() +"expect(received).not.toBeTruthy() -Expected value not to be truthy, instead received - []" +Received: []" `; exports[`.toBeTruthy(), .toBeFalsy() '[]' is truthy 2`] = ` "expect(received).toBeFalsy() -Expected value to be falsy, instead received - []" +Received: []" `; exports[`.toBeTruthy(), .toBeFalsy() '[Function anonymous]' is truthy 1`] = ` -"expect(received).not.toBeTruthy() +"expect(received).not.toBeTruthy() -Expected value not to be truthy, instead received - [Function anonymous]" +Received: [Function anonymous]" `; exports[`.toBeTruthy(), .toBeFalsy() '[Function anonymous]' is truthy 2`] = ` "expect(received).toBeFalsy() -Expected value to be falsy, instead received - [Function anonymous]" +Received: [Function anonymous]" `; exports[`.toBeTruthy(), .toBeFalsy() '{}' is truthy 1`] = ` -"expect(received).not.toBeTruthy() +"expect(received).not.toBeTruthy() -Expected value not to be truthy, instead received - {}" +Received: {}" `; exports[`.toBeTruthy(), .toBeFalsy() '{}' is truthy 2`] = ` "expect(received).toBeFalsy() -Expected value to be falsy, instead received - {}" +Received: {}" `; exports[`.toBeTruthy(), .toBeFalsy() '0' is falsy 1`] = ` "expect(received).toBeTruthy() -Expected value to be truthy, instead received - 0" +Received: 0" `; exports[`.toBeTruthy(), .toBeFalsy() '0' is falsy 2`] = ` -"expect(received).not.toBeFalsy() +"expect(received).not.toBeFalsy() -Expected value not to be falsy, instead received - 0" +Received: 0" `; exports[`.toBeTruthy(), .toBeFalsy() '0.5' is truthy 1`] = ` -"expect(received).not.toBeTruthy() +"expect(received).not.toBeTruthy() -Expected value not to be truthy, instead received - 0.5" +Received: 0.5" `; exports[`.toBeTruthy(), .toBeFalsy() '0.5' is truthy 2`] = ` "expect(received).toBeFalsy() -Expected value to be falsy, instead received - 0.5" +Received: 0.5" `; exports[`.toBeTruthy(), .toBeFalsy() '1' is truthy 1`] = ` -"expect(received).not.toBeTruthy() +"expect(received).not.toBeTruthy() -Expected value not to be truthy, instead received - 1" +Received: 1" `; exports[`.toBeTruthy(), .toBeFalsy() '1' is truthy 2`] = ` "expect(received).toBeFalsy() -Expected value to be falsy, instead received - 1" +Received: 1" `; exports[`.toBeTruthy(), .toBeFalsy() 'Infinity' is truthy 1`] = ` -"expect(received).not.toBeTruthy() +"expect(received).not.toBeTruthy() -Expected value not to be truthy, instead received - Infinity" +Received: Infinity" `; exports[`.toBeTruthy(), .toBeFalsy() 'Infinity' is truthy 2`] = ` "expect(received).toBeFalsy() -Expected value to be falsy, instead received - Infinity" +Received: Infinity" `; exports[`.toBeTruthy(), .toBeFalsy() 'Map {}' is truthy 1`] = ` -"expect(received).not.toBeTruthy() +"expect(received).not.toBeTruthy() -Expected value not to be truthy, instead received - Map {}" +Received: Map {}" `; exports[`.toBeTruthy(), .toBeFalsy() 'Map {}' is truthy 2`] = ` "expect(received).toBeFalsy() -Expected value to be falsy, instead received - Map {}" +Received: Map {}" `; exports[`.toBeTruthy(), .toBeFalsy() 'NaN' is falsy 1`] = ` "expect(received).toBeTruthy() -Expected value to be truthy, instead received - NaN" +Received: NaN" `; exports[`.toBeTruthy(), .toBeFalsy() 'NaN' is falsy 2`] = ` -"expect(received).not.toBeFalsy() +"expect(received).not.toBeFalsy() -Expected value not to be falsy, instead received - NaN" +Received: NaN" `; exports[`.toBeTruthy(), .toBeFalsy() 'false' is falsy 1`] = ` "expect(received).toBeTruthy() -Expected value to be truthy, instead received - false" +Received: false" `; exports[`.toBeTruthy(), .toBeFalsy() 'false' is falsy 2`] = ` -"expect(received).not.toBeFalsy() +"expect(received).not.toBeFalsy() -Expected value not to be falsy, instead received - false" +Received: false" `; exports[`.toBeTruthy(), .toBeFalsy() 'null' is falsy 1`] = ` "expect(received).toBeTruthy() -Expected value to be truthy, instead received - null" +Received: null" `; exports[`.toBeTruthy(), .toBeFalsy() 'null' is falsy 2`] = ` -"expect(received).not.toBeFalsy() +"expect(received).not.toBeFalsy() -Expected value not to be falsy, instead received - null" +Received: null" `; exports[`.toBeTruthy(), .toBeFalsy() 'true' is truthy 1`] = ` -"expect(received).not.toBeTruthy() +"expect(received).not.toBeTruthy() -Expected value not to be truthy, instead received - true" +Received: true" `; exports[`.toBeTruthy(), .toBeFalsy() 'true' is truthy 2`] = ` "expect(received).toBeFalsy() -Expected value to be falsy, instead received - true" +Received: true" `; exports[`.toBeTruthy(), .toBeFalsy() 'undefined' is falsy 1`] = ` "expect(received).toBeTruthy() -Expected value to be truthy, instead received - undefined" +Received: undefined" `; exports[`.toBeTruthy(), .toBeFalsy() 'undefined' is falsy 2`] = ` -"expect(received).not.toBeFalsy() +"expect(received).not.toBeFalsy() -Expected value not to be falsy, instead received - undefined" +Received: undefined" `; exports[`.toBeTruthy(), .toBeFalsy() does not accept arguments 1`] = ` diff --git a/packages/expect/src/matchers.js b/packages/expect/src/matchers.js index b99c6cff12be..f82b054cf2f2 100644 --- a/packages/expect/src/matchers.js +++ b/packages/expect/src/matchers.js @@ -45,14 +45,13 @@ const matchers: MatchersObject = { const message = pass ? () => - matcherHint('.not.toBe', undefined, undefined, { + matcherHint('.toBe', undefined, undefined, { comment, + isNot: true, }) + '\n\n' + - `Expected value to not be:\n` + - ` ${printExpected(expected)}\n` + - `Received:\n` + - ` ${printReceived(received)}` + `Expected: ${printExpected(expected)}\n` + + `Received: ${printReceived(received)}` : () => { const suggestToEqual = getType(received) === getType(expected) && @@ -66,12 +65,11 @@ const matchers: MatchersObject = { return ( matcherHint('.toBe', undefined, undefined, { comment, + isNot: false, }) + '\n\n' + - `Expected value to be:\n` + - ` ${printExpected(expected)}\n` + - `Received:\n` + - ` ${printReceived(received)}` + + `Expected: ${printExpected(expected)}\n` + + `Received: ${printReceived(received)}` + (diffString ? `\n\nDifference:\n\n${diffString}` : '') + (suggestToEqual ? ` ${SUGGEST_TO_EQUAL}` : '') ); @@ -87,29 +85,15 @@ const matchers: MatchersObject = { const secondArgument = arguments.length === 3 ? 'precision' : null; ensureNumbers(actual, expected, '.toBeCloseTo'); const pass = Math.abs(expected - actual) < Math.pow(10, -precision) / 2; - const message = pass - ? () => - matcherHint('.not.toBeCloseTo', undefined, undefined, { - secondArgument, - }) + - '\n\n' + - `Expected value not to be close to (with ${printExpected( - precision, - )}-digit precision):\n` + - ` ${printExpected(expected)}\n` + - `Received:\n` + - ` ${printReceived(actual)}` - : () => - matcherHint('.toBeCloseTo', undefined, undefined, { - secondArgument, - }) + - '\n\n' + - `Expected value to be close to (with ${printExpected( - precision, - )}-digit precision):\n` + - ` ${printExpected(expected)}\n` + - `Received:\n` + - ` ${printReceived(actual)}`; + const message = () => + matcherHint('.toBeCloseTo', undefined, undefined, { + isNot: this.isNot, + secondArgument, + }) + + '\n\n' + + `Precision: ${printExpected(precision)}-digit\n` + + `Expected: ${printExpected(expected)}\n` + + `Received: ${printReceived(actual)}`; return {message, pass}; }, @@ -117,76 +101,50 @@ const matchers: MatchersObject = { toBeDefined(actual: any, expected: void) { ensureNoExpected(expected, '.toBeDefined'); const pass = actual !== void 0; - const message = pass - ? () => - matcherHint('.not.toBeDefined', 'received', '') + - '\n\n' + - `Expected value not to be defined, instead received\n` + - ` ${printReceived(actual)}` - : () => - matcherHint('.toBeDefined', 'received', '') + - '\n\n' + - `Expected value to be defined, instead received\n` + - ` ${printReceived(actual)}`; + const message = () => + matcherHint('.toBeDefined', 'received', '', { + isNot: this.isNot, + }) + + '\n\n' + + `Received: ${printReceived(actual)}`; return {message, pass}; }, toBeFalsy(actual: any, expected: void) { ensureNoExpected(expected, '.toBeFalsy'); const pass = !actual; - const message = pass - ? () => - matcherHint('.not.toBeFalsy', 'received', '') + - '\n\n' + - `Expected value not to be falsy, instead received\n` + - ` ${printReceived(actual)}` - : () => - matcherHint('.toBeFalsy', 'received', '') + - '\n\n' + - `Expected value to be falsy, instead received\n` + - ` ${printReceived(actual)}`; + const message = () => + matcherHint('.toBeFalsy', 'received', '', { + isNot: this.isNot, + }) + + '\n\n' + + `Received: ${printReceived(actual)}`; return {message, pass}; }, toBeGreaterThan(actual: number, expected: number) { ensureNumbers(actual, expected, '.toBeGreaterThan'); const pass = actual > expected; - const message = pass - ? () => - matcherHint('.not.toBeGreaterThan') + - '\n\n' + - `Expected value not to be greater than:\n` + - ` ${printExpected(expected)}\n` + - `Received:\n` + - ` ${printReceived(actual)}` - : () => - matcherHint('.toBeGreaterThan') + - '\n\n' + - `Expected value to be greater than:\n` + - ` ${printExpected(expected)}\n` + - `Received:\n` + - ` ${printReceived(actual)}`; + const message = () => + matcherHint('.toBeGreaterThan', undefined, undefined, { + isNot: this.isNot, + }) + + '\n\n' + + `Expected: ${printExpected(expected)}\n` + + `Received: ${printReceived(actual)}`; return {message, pass}; }, toBeGreaterThanOrEqual(actual: number, expected: number) { ensureNumbers(actual, expected, '.toBeGreaterThanOrEqual'); const pass = actual >= expected; - const message = pass - ? () => - matcherHint('.not.toBeGreaterThanOrEqual') + - '\n\n' + - `Expected value not to be greater than or equal:\n` + - ` ${printExpected(expected)}\n` + - `Received:\n` + - ` ${printReceived(actual)}` - : () => - matcherHint('.toBeGreaterThanOrEqual') + - '\n\n' + - `Expected value to be greater than or equal:\n` + - ` ${printExpected(expected)}\n` + - `Received:\n` + - ` ${printReceived(actual)}`; + const message = () => + matcherHint('.toBeGreaterThanOrEqual', undefined, undefined, { + isNot: this.isNot, + }) + + '\n\n' + + `Expected: ${printExpected(expected)}\n` + + `Received: ${printReceived(actual)}`; return {message, pass}; }, @@ -195,7 +153,9 @@ const matchers: MatchersObject = { if (constType !== 'function') { throw new Error( - matcherHint('[.not].toBeInstanceOf', 'value', 'constructor') + + matcherHint('.toBeInstanceOf', 'value', 'constructor', { + isNot: this.isNot, + }) + `\n\n` + `Expected constructor to be a function. Instead got:\n` + ` ${printExpected(constType)}`, @@ -205,23 +165,26 @@ const matchers: MatchersObject = { const message = pass ? () => - matcherHint('.not.toBeInstanceOf', 'value', 'constructor') + + matcherHint('.toBeInstanceOf', 'value', 'constructor', { + isNot: this.isNot, + }) + '\n\n' + - `Expected value not to be an instance of:\n` + - ` ${printExpected(constructor.name || constructor)}\n` + - `Received:\n` + - ` ${printReceived(received)}\n` + `Expected constructor: ${EXPECTED_COLOR( + constructor.name || constructor, + )}\n` + + `Received value: ${printReceived(received)}` : () => - matcherHint('.toBeInstanceOf', 'value', 'constructor') + + matcherHint('.toBeInstanceOf', 'value', 'constructor', { + isNot: this.isNot, + }) + '\n\n' + - `Expected value to be an instance of:\n` + - ` ${printExpected(constructor.name || constructor)}\n` + - `Received:\n` + - ` ${printReceived(received)}\n` + - `Constructor:\n` + - ` ${printReceived( + `Expected constructor: ${EXPECTED_COLOR( + constructor.name || constructor, + )}\n` + + `Received constructor: ${RECEIVED_COLOR( received.constructor && received.constructor.name, - )}`; + )}\n` + + `Received value: ${printReceived(received)}`; return {message, pass}; }, @@ -229,110 +192,74 @@ const matchers: MatchersObject = { toBeLessThan(actual: number, expected: number) { ensureNumbers(actual, expected, '.toBeLessThan'); const pass = actual < expected; - const message = pass - ? () => - matcherHint('.not.toBeLessThan') + - '\n\n' + - `Expected value not to be less than:\n` + - ` ${printExpected(expected)}\n` + - `Received:\n` + - ` ${printReceived(actual)}` - : () => - matcherHint('.toBeLessThan') + - '\n\n' + - `Expected value to be less than:\n` + - ` ${printExpected(expected)}\n` + - `Received:\n` + - ` ${printReceived(actual)}`; + const message = () => + matcherHint('.toBeLessThan', undefined, undefined, { + isNot: this.isNot, + }) + + '\n\n' + + `Expected: ${printExpected(expected)}\n` + + `Received: ${printReceived(actual)}`; return {message, pass}; }, toBeLessThanOrEqual(actual: number, expected: number) { ensureNumbers(actual, expected, '.toBeLessThanOrEqual'); const pass = actual <= expected; - const message = pass - ? () => - matcherHint('.not.toBeLessThanOrEqual') + - '\n\n' + - `Expected value not to be less than or equal:\n` + - ` ${printExpected(expected)}\n` + - `Received:\n` + - ` ${printReceived(actual)}` - : () => - matcherHint('.toBeLessThanOrEqual') + - '\n\n' + - `Expected value to be less than or equal:\n` + - ` ${printExpected(expected)}\n` + - `Received:\n` + - ` ${printReceived(actual)}`; + const message = () => + matcherHint('.toBeLessThanOrEqual', undefined, undefined, { + isNot: this.isNot, + }) + + '\n\n' + + `Expected: ${printExpected(expected)}\n` + + `Received: ${printReceived(actual)}`; return {message, pass}; }, toBeNaN(actual: any, expected: void) { ensureNoExpected(expected, '.toBeNaN'); const pass = Number.isNaN(actual); - const message = pass - ? () => - matcherHint('.not.toBeNaN', 'received', '') + - '\n\n' + - `Expected value not to be NaN, instead received\n` + - ` ${printReceived(actual)}` - : () => - matcherHint('.toBeNaN', 'received', '') + - '\n\n' + - `Expected value to be NaN, instead received\n` + - ` ${printReceived(actual)}`; + const message = () => + matcherHint('.toBeNaN', 'received', '', { + isNot: this.isNot, + }) + + '\n\n' + + `Received: ${printReceived(actual)}`; return {message, pass}; }, toBeNull(actual: any, expected: void) { ensureNoExpected(expected, '.toBeNull'); const pass = actual === null; - const message = pass - ? () => - matcherHint('.not.toBeNull', 'received', '') + - '\n\n' + - `Expected value not to be null, instead received\n` + - ` ${printReceived(actual)}` - : () => - matcherHint('.toBeNull', 'received', '') + - '\n\n' + - `Expected value to be null, instead received\n` + - ` ${printReceived(actual)}`; + const message = () => + matcherHint('.toBeNull', 'received', '', { + isNot: this.isNot, + }) + + '\n\n' + + `Received: ${printReceived(actual)}`; return {message, pass}; }, toBeTruthy(actual: any, expected: void) { ensureNoExpected(expected, '.toBeTruthy'); const pass = !!actual; - const message = pass - ? () => - matcherHint('.not.toBeTruthy', 'received', '') + - '\n\n' + - `Expected value not to be truthy, instead received\n` + - ` ${printReceived(actual)}` - : () => - matcherHint('.toBeTruthy', 'received', '') + - '\n\n' + - `Expected value to be truthy, instead received\n` + - ` ${printReceived(actual)}`; + const message = () => + matcherHint('.toBeTruthy', 'received', '', { + isNot: this.isNot, + }) + + '\n\n' + + `Received: ${printReceived(actual)}`; return {message, pass}; }, toBeUndefined(actual: any, expected: void) { ensureNoExpected(expected, '.toBeUndefined'); const pass = actual === void 0; - const message = pass - ? () => - matcherHint('.not.toBeUndefined', 'received', '') + - '\n\n' + - `Expected value not to be undefined, instead received\n` + - ` ${printReceived(actual)}` - : () => - matcherHint('.toBeUndefined', 'received', '') + - '\n\n' + - `Expected value to be undefined, instead received\n` + - ` ${printReceived(actual)}`; + const message = () => + matcherHint('.toBeUndefined', 'received', '', { + isNot: this.isNot, + }) + + '\n\n' + + `Received: ${printReceived(actual)}`; return {message, pass}; }, diff --git a/packages/jest-matcher-utils/src/index.js b/packages/jest-matcher-utils/src/index.js index 518f5c24ba74..f5df6c90901c 100644 --- a/packages/jest-matcher-utils/src/index.js +++ b/packages/jest-matcher-utils/src/index.js @@ -153,14 +153,17 @@ export const matcherHint = ( options: { comment?: string, isDirectExpectCall?: boolean, + isNot?: boolean, secondArgument?: ?string, } = {}, ) => { - const {comment, isDirectExpectCall, secondArgument} = options; + const {comment, isDirectExpectCall, isNot, secondArgument} = options; return ( chalk.dim('expect' + (isDirectExpectCall ? '' : '(')) + RECEIVED_COLOR(received) + - chalk.dim((isDirectExpectCall ? '' : ')') + matcherName + '(') + + (isNot + ? `${chalk.dim(').')}not${chalk.dim(matcherName + '(')}` + : chalk.dim((isDirectExpectCall ? '' : ')') + matcherName + '(')) + EXPECTED_COLOR(expected) + (secondArgument ? `${chalk.dim(', ')}${EXPECTED_COLOR(secondArgument)}` From 55d967310a6e61a47f1df5c1e750485388b344c2 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Fri, 9 Feb 2018 20:14:29 -0500 Subject: [PATCH 2/3] Update changelog and one more snapshot plus fix Windows test --- CHANGELOG.md | 7 +++++++ integration-tests/__tests__/jasmine_async.test.js | 2 +- .../src/__tests__/__snapshots__/matchers.test.js.snap | 6 ++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f546890f9800..636d2a4d46d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## master +### Features + +* `[jest-matcher-utils]` Add `isNot` option to `matcherHint` function + ([#5512](https://github.com/facebook/jest/pull/5512)) + ## jest 22.2.2 ### Fixes @@ -37,6 +42,8 @@ * `[diff-sequences]` New package compares items in two sequences to find a **longest common subsequence**. ([#5407](https://github.com/facebook/jest/pull/5407)) +* `[jest-matcher-utils]` Add `comment` option to `matcherHint` function + ([#5437](https://github.com/facebook/jest/pull/5437)) * `[jest-config]` Allow lastComit and changedFilesWithAncestor via JSON config ([#5476](https://github.com/facebook/jest/pull/5476)) * `[jest-util]` Add deletion to `process.env` as well diff --git a/integration-tests/__tests__/jasmine_async.test.js b/integration-tests/__tests__/jasmine_async.test.js index 57ab317f2117..bb037fbbc811 100644 --- a/integration-tests/__tests__/jasmine_async.test.js +++ b/integration-tests/__tests__/jasmine_async.test.js @@ -138,7 +138,7 @@ describe('async jasmine', () => { expect(result.status).toBe(1); expect(result.json.testResults[0].message).toEqual( - expect.stringContaining('Expected value to be truthy, instead received'), + expect.stringContaining('Received:'), ); }); diff --git a/packages/jest-jasmine2/src/__tests__/__snapshots__/matchers.test.js.snap b/packages/jest-jasmine2/src/__tests__/__snapshots__/matchers.test.js.snap index d94175512f98..1644bcce2919 100644 --- a/packages/jest-jasmine2/src/__tests__/__snapshots__/matchers.test.js.snap +++ b/packages/jest-jasmine2/src/__tests__/__snapshots__/matchers.test.js.snap @@ -3,8 +3,6 @@ exports[`matchers proxies matchers to expect 1`] = ` "expect(received).toBe(expected) // Object.is equality -Expected value to be: - 2 -Received: - 1" +Expected: 2 +Received: 1" `; From cdd7979fd0e80b9cdbc57223df8c01210e22a383 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Fri, 9 Feb 2018 20:53:51 -0500 Subject: [PATCH 3/3] Update snapshot in failures integration test --- .../__tests__/__snapshots__/failures.test.js.snap | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/integration-tests/__tests__/__snapshots__/failures.test.js.snap b/integration-tests/__tests__/__snapshots__/failures.test.js.snap index 80542fc0622e..e40d65ddf914 100644 --- a/integration-tests/__tests__/__snapshots__/failures.test.js.snap +++ b/integration-tests/__tests__/__snapshots__/failures.test.js.snap @@ -38,8 +38,7 @@ exports[`not throwing Error objects 4`] = ` ✕ throws when there are not assertions ● .assertions() › throws expect(received).toBeTruthy() - Expected value to be truthy, instead received - false + Received: false 11 | const throws = () => { 12 | expect.assertions(2); > 13 | expect(false).toBeTruthy(); @@ -52,8 +51,7 @@ exports[`not throwing Error objects 4`] = ` Expected two assertions to be called but received one assertion call. ● .assertions() › throws on redeclare of assertion count expect(received).toBeTruthy() - Expected value to be truthy, instead received - false + Received: false 15 | const redeclare = () => { 16 | expect.assertions(1); > 17 | expect(false).toBeTruthy();