throwsPropError function
A matcher to verify that a PropError
is thrown with the provided propName
and optional message
.
This matcher will not work on PropError
s found within UiComponent2.propTypes
. When testing
prop type validation - use logsPropError.
Note: The message
is matched rather than the Error instance due to Dart's wrapping of all throw
as a DomException
Implementation
Matcher throwsPropError(String propName, [String message = '']) {
return throwsA(anyOf(
hasToStringValue('V8 Exception'), /* workaround for https://github.com/dart-lang/sdk/issues/26093 */
hasToStringValue(contains('PropError: Prop $propName. $message'.trim()))
));
}