startRecordingValidationWarnings function

void startRecordingValidationWarnings()

Starts recording an OverReact ValidationUtil.warning.

For use within setUp:

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: stopRecordingValidationWarnings, verifyValidationWarning, rejectValidationWarning

Implementation

void startRecordingValidationWarnings() {
  _validationWarnings = [];
  ValidationUtil.onWarning = _recordValidationWarning;
}