Closed gnapse closed 10 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
1fb156c
) 100.00% compared to head (a2cdb76
) 100.00%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:tada: This PR is included in version 6.3.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
What:
Enhances
.toHaveClass
to also support receiving regular expressions in its params, to be matched against the target element's class names.Since this is a newly supported argument type, this is not a breaking change. Any code calling
.toHaveClass
with strings only (the only supported use so far) that code will continue to work as before.Why:
Closes #556
It enables more freedom when checking an element's class names. For instance, in some preprocessed CSS scenarios, class names are generated programmatically, and the writer of the test cannot know in advance the exact class name, though they may know a substring or pattern in it.
How:
By checking, in a handful of places of the relevant code, whether a value is a string or a regular expression. If it is a regular expression, then we do a different check.
Also, in the particular case of passing
{exact:true}
options to.toHaveClass
, we disable regular expressions support, and throw an error if regular expressions are found in the arguments.Checklist: