I am trying to test a custom drawer but find it hard opening it in the test, tried the following to begin with and even this test doesn't pass. The error is: Bad state: no element
.
void main() {
testWidgets('my drawer test', (WidgetTester tester) async {
final displayName = "displayName";
var drawKey = UniqueKey();
await tester.pumpWidget(MaterialApp(
home: Scaffold(
drawer: Drawer(key: drawKey, child: Text(displayName),),
)));
await tester.tap(find.byKey(drawKey));
expect(find.text(displayName), findsOneWidget);
});
}