use throwsA (#82238)

This commit is contained in:
Alexandre Ardhuin
2021-05-11 19:19:01 +02:00
committed by GitHub
parent 7b9a175557
commit df3662b15e
22 changed files with 311 additions and 297 deletions

View File

@@ -26,12 +26,14 @@ void main() {
});
test('waitForAbsent should time out waiting for text "present" to disappear', () async {
try {
await driver.waitForAbsent(presentText, timeout: const Duration(seconds: 1));
fail('expected DriverError');
} on DriverError catch (error) {
expect(error.message, contains('Timeout while executing waitForAbsent'));
}
await expectLater(
() => driver.waitForAbsent(presentText, timeout: const Duration(seconds: 1)),
throwsA(isA<DriverError>().having(
(DriverError error) => error.message,
'message',
contains('Timeout while executing waitForAbsent'),
)),
);
});
test('waitForAbsent should resolve when text "present" disappears', () async {
@@ -51,12 +53,14 @@ void main() {
});
test('waitFor times out waiting for "present" to reappear', () async {
try {
await driver.waitFor(presentText, timeout: const Duration(seconds: 1));
fail('expected DriverError');
} on DriverError catch (error) {
expect(error.message, contains('Timeout while executing waitFor'));
}
await expectLater(
() => driver.waitFor(presentText, timeout: const Duration(seconds: 1)),
throwsA(isA<DriverError>().having(
(DriverError error) => error.message,
'message',
contains('Timeout while executing waitFor'),
)),
);
});
test('waitFor should resolve when text "present" reappears', () async {