Add custom message for toBe() matcher when object equality check fails
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
getJasmineRequireObj().toBe = function() {
|
||||
getJasmineRequireObj().toBe = function($j) {
|
||||
/**
|
||||
* {@link expect} the actual value to be `===` to the expected value.
|
||||
* @function
|
||||
@@ -8,10 +8,14 @@ getJasmineRequireObj().toBe = function() {
|
||||
* expect(thing).toBe(realThing);
|
||||
*/
|
||||
function toBe() {
|
||||
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
var customMessage = 'Expected ' + $j.pp(expected) + ' to be ' + $j.pp(actual) + '. Tip: To check for deep equality, use .toEqual() instead of .toBe().';
|
||||
|
||||
return {
|
||||
pass: actual === expected
|
||||
pass: actual === expected,
|
||||
message: typeof expected === 'object' ? customMessage : undefined,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user