Flutter Testing: InputChip click on delete
131
Your finder is finding and tapping the InputChip
itself, not the "X" on the Chip.
Your finder should look something like:
find.descendant(
of: find.byKey(Key(label.id)),
matching: find.byIcon(Icons.cancel),
);
This says "find the descendent of the InputChip
who is the cancel
Icon
. Then you can tap that if you'd like :)
When you're missing a tap-target, or aren't sure what is happening in the test, have a look at the console after running debugDumpApp();
Author by
oberprah
Updated on December 26, 2022Comments
-
oberprah over 1 year
I use InputChips in my app.
InputChip( key: Key(label.id), label: Text(label.name), onDeleted: () => deleteChip(), ),
I want now to create unit tests to test the delete function. Unfortunatly I found no way to press the delete icon of the chip in the unit test. With
await tester.tap(find.byKey(Key('1')));
it's possible to find the chip. How can I now define that I want to click the delete icon on the chip?