Skip to content

Instantly share code, notes, and snippets.

@alexandrebodin
Created May 31, 2017 07:04
Show Gist options
  • Save alexandrebodin/b905b4f732a64c6d7a6dcf6cfccdf8b0 to your computer and use it in GitHub Desktop.
Save alexandrebodin/b905b4f732a64c6d7a6dcf6cfccdf8b0 to your computer and use it in GitHub Desktop.
jest expect add asymetricMatchers
const definedProto = {
$$typeof: Symbol.for('jest.asymmetricMatcher'),
asymmetricMatch(o) {
return typeof o !== undefined;
},
toAsymmetricMatcher() {
return 'Defined';
},
toString() {
return 'Defined';
},
};
const defined = () => {
return Object.create(definedProto);
};
expect.defined = defined;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment