testBrowser function

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

Implementation

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

      var binding = BrowserAppBinding();
      var tester = BrowserTester._(binding);

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

      // Clear all nodes
      web.document.body?.replaceChildren([].jsify()!);
    },
    skip: skip,
    timeout: timeout,
    tags: tags,
  );
}