mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
LibJS: Add custom details to toBe{True, False} shown on failure
Any test with multiple expect(...).toBe{True, False} checks is very hard to debug.
This commit is contained in:
parent
fa030d7b9c
commit
0d8bab82f0
1 changed files with 6 additions and 4 deletions
|
@ -214,24 +214,26 @@ class ExpectationError extends Error {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toBeTrue() {
|
toBeTrue(customDetails = undefined) {
|
||||||
this.__doMatcher(() => {
|
this.__doMatcher(() => {
|
||||||
this.__expect(
|
this.__expect(
|
||||||
this.target === true,
|
this.target === true,
|
||||||
() =>
|
() =>
|
||||||
`toBeTrue: expected target to be true, got _${valueToString(this.target)}_`
|
`toBeTrue: expected target to be true, got _${valueToString(this.target)}_${
|
||||||
|
customDetails ? ` (${customDetails})` : ""
|
||||||
|
}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toBeFalse() {
|
toBeFalse(customDetails = undefined) {
|
||||||
this.__doMatcher(() => {
|
this.__doMatcher(() => {
|
||||||
this.__expect(
|
this.__expect(
|
||||||
this.target === false,
|
this.target === false,
|
||||||
() =>
|
() =>
|
||||||
`toBeFalse: expected target to be false, got _${valueToString(
|
`toBeFalse: expected target to be false, got _${valueToString(
|
||||||
this.target
|
this.target
|
||||||
)}_`
|
)}_${customDetails ?? ""}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue