flutter / flutter/flutter

[espresso] (feature request) doesNotExist assertion for widgets

Open
#160,599 1 comment 0 reactions 0 assignees View on GitHub
c: new feature c: proposal p: espresso P3 package platform-android team-android triaged-android
Dominant language
Dart
Stars
179k
Forks
31.1k
PR merge metrics
PR metrics pending

Description

### Use case

I'm trying to add an Android integration test to one of the packages, I use Espresso for it, like suggested in [Plugin-Tests.md](https://github.com/flutter/flutter/blob/master/docs/ecosystem/testing/Plugin-Tests.md). I need to check if a widget is not rendered on the screen, after that I'll perform an action, and then verify the existence of a widget again (this time it should be visible).

In native Espresso library we can do that with `ViewAssertions.doesNotExist`, but there's no equivalent in Espresso for Flutter - we only have `isExisting` here.

### Proposal

I'd suggest adding another static function (`doesNotExist`) to `FlutterMatchers` class. This function would return a proper matcher that would check if a given Flutter widget exists. If it does, it should throw an exception.

Example code:

```dart
WidgetInteraction playButton = onFlutterWidget(withValueKey("Play"));
playButton.check(matches(doesNotExist()));
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.