setup<T> method

Future<T> setup<T>(
  1. String name,
  2. Future<T> body()
)

Emits a step that has no frame — see document and notification.

Everything a captured step does about position, parent, branch and replay, and none of what it does about pixels. It deliberately does not hand over the capture being held: nothing was drawn here, so a screen after this beat may still name the frame before it, and the chain stays linear because the position map records the chain's head rather than the step a name landed on. Runs body as a step with a duration and no picture.

The body runs in-process, so the network funnel already records its exchanges on this step. A consumer's "create an account through the API, read the confirmation mail, confirm it" becomes visible on the flow without changing. Under the fake clock the body gets a real-async turn, the way runAsync does, because what a setup awaits is real.

var token = await s.setup('fresh account', () => api.register(...));
await s.pumpWidget(app(initialToken: token));

Implementation

Future<T> setup<T>(String name, Future<T> Function() body) async {
  var watch = Stopwatch()..start();
  var result = scenarioHarnessTime.isReal
      ? await body()
      : (await watchRunAsync(() => tester.runAsync(body))) as T;
  await _beat(
    kind: ScenarioCaptureKind.setup,
    verb: 'setup',
    name: name,
    ms: watch.elapsedMilliseconds,
  );
  return result;
}