testClient function

  1. @isTest
void testClient(
  1. String description,
  2. FutureOr<void> callback(
    1. ClientTester tester
    ), {
  3. String location = '/',
  4. bool? skip,
  5. Timeout? timeout,
  6. Object? tags,
})

Implementation

@isTest
void testClient(
  String description,
  FutureOr<void> Function(ClientTester tester) callback, {
  String location = '/',
  bool? skip,
  Timeout? timeout,
  Object? tags,
}) {
  test(
    description,
    () async {
      if (web.window.location.pathname != location) {
        web.window.history.replaceState(null, 'Test', location);
      }

      final binding = ClientAppBinding();
      final tester = ClientTester._(binding);

      await binding.runTest(() async {
        await callback(tester);
      });

      // Clear all nodes
      web.document.body?.replaceChildren(<web.Node>[].toJS);
    },
    skip: skip,
    timeout: timeout,
    tags: tags,
  );
}