summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-04-23 20:12:10 +0200
committerLinus Groh <mail@linusgroh.de>2021-04-23 20:30:52 +0200
commitd400be05ecaa14095eddf531e123b5e676187cb6 (patch)
tree24b860723756d961237befc553ae635c640a72a3 /Userland
parent0d2602c900757a49f228d6a4099f8dd7993a4982 (diff)
downloadserenity-d400be05ecaa14095eddf531e123b5e676187cb6.zip
LibJS/Tests: Improve expectation error details
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Tests/test-common.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/Userland/Libraries/LibJS/Tests/test-common.js b/Userland/Libraries/LibJS/Tests/test-common.js
index eaf107d0ed..ec54dfddf2 100644
--- a/Userland/Libraries/LibJS/Tests/test-common.js
+++ b/Userland/Libraries/LibJS/Tests/test-common.js
@@ -65,8 +65,7 @@ class ExpectationError extends Error {
this.__doMatcher(() => {
this.__expect(
Object.is(this.target, value),
- () =>
- "toBe: expected _" + String(value) + "_, got _" + String(this.target) + "_"
+ () => `toBe: expected _${String(value)}_, got _${String(this.target)}_`
);
});
}
@@ -75,11 +74,11 @@ class ExpectationError extends Error {
toBeCloseTo(value) {
this.__expect(
typeof this.target === "number",
- () => "toBeCloseTo: target not of type number"
+ () => `toBeCloseTo: expected target of type number, got ${typeof value}`
);
this.__expect(
typeof value === "number",
- () => "toBeCloseTo: argument not of type number"
+ () => `toBeCloseTo: expected argument of type number, got ${typeof value}`
);
this.__doMatcher(() => {
@@ -133,7 +132,10 @@ class ExpectationError extends Error {
toBeDefined() {
this.__doMatcher(() => {
- this.__expect(this.target !== undefined, () => "toBeDefined: target was undefined");
+ this.__expect(
+ this.target !== undefined,
+ () => "toBeDefined: expected target to be defined, got undefined"
+ );
});
}
@@ -153,7 +155,10 @@ class ExpectationError extends Error {
this.__doMatcher(() => {
this.__expect(
this.target === undefined,
- () => "toBeUndefined: target was not undefined"
+ () =>
+ `toBeUndefined: expected target to be undefined, got _${String(
+ this.target
+ )}_`
);
});
}
@@ -162,7 +167,7 @@ class ExpectationError extends Error {
this.__doMatcher(() => {
this.__expect(
isNaN(this.target),
- () => "toBeNaN: target was _" + String(this.target) + "_, not NaN"
+ () => `toBeNaN: expected target to be NaN, got _${String(this.target)}_`
);
});
}