How to pass a custom error message to a jasmine matcher?

Update 2022; Use .withContext(...) method instead of below (as optional parameter is deprecated).


Jasmine already supports optional parameter in all matchers (toBe, toContain, and others), so you can use:

expect(true).toBe(false, 'True should be false').

Then in output it will look like this:

Message:
    Expected true to be false, 'True should be false'.

Link to commit (this is not described in documentation):
https://github.com/ronanamsterdam/DefinitelyTyped/commit/ff104ed7cc13a3eb2e89f46242c4dbdbbe66665e

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)