logsPropError function

_PropTypeLogMatcher logsPropError(
  1. String propName, [
  2. String message = ''
])

A matcher to verify that a PropError is returned within UiComponent2.propTypes with the provided propName and optional message.

This matcher only works for PropErrors that are returned within UiComponent2.propTypes. If you are testing a PropError that is thrown anywhere else within a component, use throwsPropError.

This matcher is built on top of logsPropTypeWarning and has the same behavior of running the provided callback, swallowing errors that occur, and looking for the expected PropError in the resulting logs.

NOTE: Will only produce failures when tests are run using the dartdevc compiler since the react package "tree shakes" propTypes from dart2js compiled output.

Implementation

_PropTypeLogMatcher logsPropError(String propName, [String message = '']) {
  return logsPropTypeWarning('PropError: Prop $propName. $message'.trim());
}