inertNetworkMessage function

  1. @visibleForTesting
String? inertNetworkMessage(
  1. String scenario,
  2. ScenarioNetwork reach, {
  3. required bool stated,
  4. required int requests,
})

The sentence a scenario owes when it stated a mode and then asked for nothing, or null.

A mode is a claim about what this scenario's requests reach, and zero requests contradicts it. The usual cause is not the mode but the app: a layer that answers before anything opens an HttpClient is a layer the funnel cannot see, and the failure is silent in both directions — the screen shows a broken-image placeholder and the suite goes green.

Only a scenario(network: ...) is held to this. A folder's runScenarios(network: ...) and the project's fw.network(...) are defaults over a whole suite, where most scenarios legitimately touch nothing, and warning per scenario there would be dozens of lines saying that a login flow did not fetch anything. Stating a mode on one scenario is a sentence about that scenario, and this is what it means for it to have turned out false.

Implementation

@visibleForTesting
String? inertNetworkMessage(
  String scenario,
  ScenarioNetwork reach, {
  required bool stated,
  required int requests,
}) {
  if (!stated || requests > 0 || reach == ScenarioNetwork.off) return null;
  return '"$scenario" sets `network: ${reach.name}` but made no http '
      'request, so the setting had no effect. Only a request that opens an '
      "`HttpClient` is caught. That covers the app's own client, everything "
      'built on it (`package:http`, `dio`) and `NetworkImage`. A layer that '
      'answers without opening a client is not caught. The common case is '
      '`CachedNetworkImage`: its bytes come from a `BaseCacheManager`, and '
      'the no-op manager a project writes for tests fails every url without '
      'opening anything. A manager whose `getFileStream` passes through to a '
      'plain `HttpClient` is caught like any other request.';
}