throwsPropError_Required function

Matcher throwsPropError_Required(
  1. String propName, [
  2. String? message = ''
])

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

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

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

Implementation

Matcher throwsPropError_Required(String propName, [String? message = '']) {
  return throwsA(anyOf(
      hasToStringValue('V8 Exception'), /* workaround for https://github.com/dart-lang/sdk/issues/26093 */
      hasToStringValue(contains('RequiredPropError: Prop $propName is required. $message'.trim()))
  ));
}