Last active
December 16, 2020 03:58
-
-
Save joeybeninghove/c4e5cd64be4cb71d8c0b3f5c537c76f6 to your computer and use it in GitHub Desktop.
toHaveCssClass custom matcher for jest-dom
This file contains hidden or 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
expect.extend({ | |
toHaveCssClass(received, cssClass) { | |
const pass = received.querySelector(`.${cssClass}`) !== undefined; | |
return { | |
message: () => this.isNot ? `${cssClass} was found` : `${cssClass} not found`, | |
pass: pass | |
}; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment