flutter_webview_plugin icon indicating copy to clipboard operation
flutter_webview_plugin copied to clipboard

Testing evalJavascript failure

Open Z6P0 opened this issue 4 years ago • 0 comments

I try to run a simple test with the FlutterWebviewPlugin but I can't get it to work.

void main() {
  testWidgets('Test', (WidgetTester tester) async {
    var plugin = FlutterWebviewPlugin();
    await tester.pumpWidget(MaterialApp(
      home: Scaffold(
        body: Center(
          child: FutureBuilder<String?>(
            // future: Future.value('2'),
            future: plugin.launch('', hidden: false).then((_) => plugin.evalJavascript('1+1')),
            builder: (context, snapshot) {
              if (snapshot.hasError) throw snapshot.error!;
              if (!snapshot.hasData) return Text('...');
              return Text(snapshot.data!);
            },
          ),
        ),
      ),
    ));
    // expect(find.text('...'), findsOneWidget);
    expect(find.text('2'), findsOneWidget); // TestFailure
  });
}

Z6P0 avatar Aug 20 '21 09:08 Z6P0