mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-27 01:50:24 +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
Notes:
sideshowbarker
2024-07-17 09:49:33 +09:00
Author: https://github.com/davidot Commit: https://github.com/SerenityOS/serenity/commit/0d8bab82f0 Pull-request: https://github.com/SerenityOS/serenity/pull/16630 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/linusg ✅
1 changed files with 6 additions and 4 deletions
|
@ -214,24 +214,26 @@ class ExpectationError extends Error {
|
|||
});
|
||||
}
|
||||
|
||||
toBeTrue() {
|
||||
toBeTrue(customDetails = undefined) {
|
||||
this.__doMatcher(() => {
|
||||
this.__expect(
|
||||
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.__expect(
|
||||
this.target === false,
|
||||
() =>
|
||||
`toBeFalse: expected target to be false, got _${valueToString(
|
||||
this.target
|
||||
)}_`
|
||||
)}_${customDetails ?? ""}`
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue