Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thom-nic/5a3720808f3c5e537bdc to your computer and use it in GitHub Desktop.
Save thom-nic/5a3720808f3c5e537bdc to your computer and use it in GitHub Desktop.
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