From 0fe97cdfe491d4a4e0f8490fb409e1f075b14b3b Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Tue, 22 Feb 2022 07:47:48 +0330 Subject: [PATCH] LibJS: Print the expected and received value on expect.toEqual() failure 'ExpectationError' is hardly an actionable error message. --- Userland/Libraries/LibJS/Tests/test-common.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Tests/test-common.js b/Userland/Libraries/LibJS/Tests/test-common.js index b02c9cb287..a43477902e 100644 --- a/Userland/Libraries/LibJS/Tests/test-common.js +++ b/Userland/Libraries/LibJS/Tests/test-common.js @@ -280,7 +280,13 @@ class ExpectationError extends Error { toEqual(value) { this.__doMatcher(() => { - this.__expect(deepEquals(this.target, value)); + this.__expect( + deepEquals(this.target, value), + () => + `Expected _${valueToString(value)}_, but got _${valueToString( + this.target + )}_` + ); }); }