-
-
Save dathi/0de66fc0e00f263ca40ce5d18d53e8d6 to your computer and use it in GitHub Desktop.
Jasmine Matcher instanceof
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
beforeEach(function() { | |
this.addMatchers({ | |
toBeInstanceOf: function(expectedInstance) { | |
var actual = this.actual; | |
var notText = this.isNot ? " not" : ""; | |
this.message = function() { | |
return "Expected " + actual.constructor.name + notText + " is instance of " + expectedInstance.name; | |
}; | |
return actual instanceof expectedInstance; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment