Sfoglia il codice sorgente

LibJS: Print the expected and received value on expect.toEqual() failure

'ExpectationError' is hardly an actionable error message.
Ali Mohammad Pur 3 anni fa
parent
commit
0fe97cdfe4
1 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 7 1
      Userland/Libraries/LibJS/Tests/test-common.js

+ 7 - 1
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
+                        )}_`
+                );
             });
         }