throwsPropError_Value function

Matcher throwsPropError_Value(
  1. dynamic invalidValue,
  2. String propName, [
  3. String message = ''
])

A matcher to verify that a PropError.value is thrown with the provided invalidValue, propName, and optional message.

This matcher will not work on PropError.values found within UiComponent2.propTypes. When testing prop type validation - use logsPropValueError.

Note: The message is matched rather than the Error instance due to Dart's wrapping of all throw as a DomException

Implementation

Matcher throwsPropError_Value(dynamic invalidValue, String propName, [String message = '']) {
  return throwsA(anyOf(
      hasToStringValue('V8 Exception'), /* workaround for https://github.com/dart-lang/sdk/issues/26093 */
      hasToStringValue(contains('InvalidPropValueError: Prop $propName set to $invalidValue. '
          '$message'.trim()
      ))
  ));
}