Tests with @TestOn('browser') are not executed by bots
I added this test and the bots passed:
@TestOn('browser')
import 'package:flutter_test/flutter_test.dart';
void main() {
test('I must fail', () async {
expect(1, 2);
});
}
We need to migrate all tests with this annotation. Related issue: https://github.com/flutter/devtools/issues/2437
Related discussion:
Kenzie: Hey Yegor! Is there updated guidance for writing tests for Flutter web? We are hitting an issue in DevTools right now where we wanted to add "TestOn("browser")" to our test so that it runs on a web target, and discovered that that is no longer supported. In reading through a rabbit hole of issues (example https://github.com/flutter/flutter/issues/50594), I also discovered that flutter test --platform=chrome is no longer supported / recommended. Everything I read was from 2020, so wanted to check if there was some up-to-date guidance on this. thanks.
Yegor: flutter test --platform=chrome or some variant of it is here to stay. Flutter itself uses it extensively. The reason we don't recommend it is because many people try to use this mode for integration tests where they need a real world browser environment. However, this mode tried to emulate the VM flutter_tester environment where many things are mocked out. Even the passage of time is faked using FakeAsync. So people get confused when they try to do something really asynchronous, like make an HTTP request, and it doesn't work. However, we don't mind when this mode is used by advanced users. Googlers use it in google3 and in Fuchsia and we don't get many complaints. To test something in real time and without monkey-patched browser environment we recommend package:integration_test. Some examples: https://github.com/flutter/flutter/tree/master/dev/integration_tests/web_e2e_tests/test_driver
nullsafety must be enabled to run tests with test --target chrome:
https://github.com/flutter/flutter/issues/74898
Now that we have completed the null safety migration, we may be able to revisit this. @polina-c