Search code examples
javascriptunit-testingbddjasmine

Override default jasmine error message for matchers


I want to show some custom error message when any matcher fails , suppose i call this

 expect(false).toBe(true);

obviously it would return false and error message would be

Expected false to be true 

But here i want to show my custom message . Suppose i want to show

You are expecting a false but its true .

How to do this . Thanks in advance .


Solution

  • You have to write custom matchers for this. Because the error message is hard coded in jasmine.