Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Jasmine Matcher instanceof for Jasmine 2.3 & ES6
/* eslint-env jasmine */
beforeEach(function() {
jasmine.addMatchers({
toBeInstanceOf: (util, customEqualityTesters) => {
return {
compare: (actual, expected) => {
const pass = (actual instanceof expected);
return {
pass,
message: `Expected ${actual} to ${pass ? 'not' : ''} be instance of ${expected}`,
};
},
};
},
});
});
@thom-nic
Copy link
Author

thom-nic commented Dec 4, 2015

I've found that, at least for immutable.js Records, use of expect(myObj).toBe(jasmine.any(MyRecord)) doesn't seem to work but this does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment