hasLog function

Matcher hasLog(
  1. dynamic expected, {
  2. ConsoleConfiguration? consoleConfig,
  3. bool onlyIfAssertsAreEnabled = false,
})

A Matcher used to compare a list of logs against a provided String.

Takes in a specific String and passes as long as the actual list of logs contains the expected String at any index.

In the case the actual value is a callback that is run, any errors caused by the callback will be caught and ignored. If consoleConfig is set to errorConfig, the actual list of logs will include the error message from the caught error.

Related: logsToConsole, hasNoLogs

Implementation

Matcher hasLog(dynamic expected, {ConsoleConfiguration? consoleConfig, bool onlyIfAssertsAreEnabled = false}) =>
    _LoggingFunctionMatcher(anyElement(contains(expected)), config: consoleConfig, onlyIfAssertsAreEnabled: onlyIfAssertsAreEnabled);