-
Is there a way to get chai to simply return a true/false rather than printing anything to the console? I had a look at the docs on the website but couldn't find anything obvious about configuring chai's behaviour. (And if there is, could that be added as a section on the "getting started" part of the site?) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
i think you would need to try/catch the assertion yourself assertions throw by design just like in so you'd have to have a wrapper around it that does this: function assertWithoutThrow(assertion) {
try {
assertion();
return true;
} catch {
return false;
}
}
assertWithoutThrow(() => {
assert.ok(false);
}); |
Beta Was this translation helpful? Give feedback.
-
Sounds like this is resolved! Feel free to comment again/reopen if not @Pomax 👍🏻 |
Beta Was this translation helpful? Give feedback.
-
I don't know if it's worth reopening over, but it would be nice if this advice were "easily" findable somewhere in the docs too, so that others won't end up filing a new issue again (as closed issues often don't surface on web searches etc) |
Beta Was this translation helpful? Give feedback.
i think you would need to try/catch the assertion yourself
assertions throw by design just like in
node:assert
and similarso you'd have to have a wrapper around it that does this: