run method

Future<PlaybookReport> run({
  1. PlaybookSpeed? speed,
  2. Map<String, dynamic>? data,
  3. PlaybookClock? clock,
  4. bool overlay = true,
  5. void onEvent(
    1. Map<String, Object?> event
    )?,
  6. void onScreenshot(
    1. PlaybookShot shot
    )?,
  7. PlaybookScreenshots? screenshots,
  8. double pixelRatio = 1.0,
})

Runs the playbook and returns its report.

speed overrides Playbook.speed and data overrides defaults. Pass NyTesterClock(tester) as clock in a widget test. Without overlay, no finger or caption is drawn.

onScreenshot receives the run's screenshots, chosen by screenshots (PlaybookScreenshots.auto when it's null). pixelRatio sizes them relative to the device.

A failing step doesn't throw: check PlaybookReport.passed.

Implementation

Future<PlaybookReport> run({
  PlaybookSpeed? speed,
  Map<String, dynamic>? data,
  PlaybookClock? clock,
  bool overlay = true,
  void Function(Map<String, Object?> event)? onEvent,
  void Function(PlaybookShot shot)? onScreenshot,
  PlaybookScreenshots? screenshots,
  double pixelRatio = 1.0,
}) async {
  final PlaybookSession session = await open(
    clock: clock,
    overlay: overlay,
    caption: caption,
    camera: onScreenshot == null
        ? null
        : PlaybookCamera(
            mode: screenshots ?? PlaybookScreenshots.auto,
            pixelRatio: pixelRatio,
            onShot: onScreenshot,
          ),
  );
  try {
    return await runWith(session, speed: speed, data: data, emit: onEvent);
  } finally {
    close(session);
  }
}