verifyValidationWarning function
void
verifyValidationWarning(
- dynamic warningMatcher
Verify that a validation warning(s) matching warningMatcher
were logged.
Be sure to call startRecordingValidationWarnings before any code that might log errors:
group('emits a warning to the console', () {
setUp(startRecordingValidationWarnings);
tearDown(stopRecordingValidationWarnings);
test('when <describe something that should trigger a warning>', () {
// Do something that should trigger a warning
verifyValidationWarning(/* some Matcher or String */);
});
test('unless <describe something that should NOT trigger a warning>', () {
// Do something that should NOT trigger a warning
rejectValidationWarning(/* some Matcher or String */);
});
},
// Be sure to not run these tests in JS browsers
// like Chrome, Firefox, etc. since the OverReact
// ValidationUtil.warn() method will only produce a
// console warning when compiled in "dev" mode.
testOn: '!js'
);
Related: rejectValidationWarning, startRecordingValidationWarnings, stopRecordingValidationWarnings
Implementation
void verifyValidationWarning(dynamic warningMatcher) {
expect(_validationWarnings, anyElement(warningMatcher),
reason: 'Expected some recorded warning to match: $warningMatcher'
);
}