shouldHighlightStep function

bool shouldHighlightStep(
  1. TestStep step, {
  2. bool forFailure = false,
})

Implementation

bool shouldHighlightStep(TestStep step, {bool forFailure = false}) {
  // On success there is nothing to point at for expectNoText; on failure the
  // unexpectedly visible text is exactly what the screenshot should mark.
  if (step.type == 'expectNoText' &&
      !forFailure &&
      (step.args['id']?.toString().isEmpty ?? true) &&
      step.args['target'] is! Map) {
    return false;
  }
  if (step.type == 'waitForText' ||
      step.type == 'expectText' ||
      step.type == 'expectNoText' ||
      step.type == 'waitFor' ||
      step.type == 'expectTextContains' ||
      step.type == 'scrollUntilVisible' ||
      step.type == 'expectVisible' ||
      step.type == 'expectValue' ||
      step.type == 'expectSemanticsLabel') {
    final rawText = step.args['text'];
    final anyOf = step.args['anyOf'];
    final id = step.args['id']?.toString();
    final hasText = rawText is String
        ? rawText.isNotEmpty
        : rawText is List && rawText.isNotEmpty;
    final hasAnyOf = anyOf is List && anyOf.isNotEmpty;
    final hasTarget = step.args['target'] is Map;
    return hasText ||
        hasAnyOf ||
        (id != null && id.isNotEmpty) ||
        hasTarget;
  }
  return isUserActionStep(step);
}