Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 9139edf

Browse files
author
nturgut
committed
update readme file
1 parent 90b0690 commit 9139edf

File tree

1 file changed

+44
-0
lines changed
  • e2etests/web/regular_integration_tests

1 file changed

+44
-0
lines changed

e2etests/web/regular_integration_tests/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,47 @@ flutter drive -v --target=test_driver/text_editing_integration.dart -d web-serve
3737
```
3838

3939
More details for "Running Flutter Driver tests with Web" can be found in [wiki](https://github.com/flutter/flutter/wiki/Running-Flutter-Driver-tests-with-Web).
40+
41+
## Adding screenshot tests
42+
43+
In order to test screenshot tests the tests on the driver side needs to call the `integration_test` package with an `onScreenshot` callback which can do a comparison between the `screenshotBytes` taken during the test and a golden file. We added a utility method that can do this comparison by using a golden in `flutter/goldens` repository. In order to use screenshot testing follow these steps:
44+
45+
1. Call `screenshot_support.dart` from the driver side test (example: text_editing_integration_test.dart). Default value for `diffRateFailure` is 0.5 .
46+
47+
```
48+
import 'package:regular_integration_tests/screenshot_support.dart' as test;
49+
50+
Future<void> main() async {
51+
final double kMaxDiffRateFailure = 0.1;
52+
await test.runTestWithScreenshots(diffRateFailure = kMaxDiffRateFailure );
53+
}
54+
```
55+
56+
2. In order to add the screenshot golden initially or to update the existing one, we need to set UPDATE_GOLDENS flag to environment.
57+
58+
```
59+
export UPDATE_GOLDENS=true
60+
```
61+
62+
3. Run the specific test or run all integration tests
63+
64+
```
65+
flutter drive -v --target=test_driver/text_editing_integration.dart -d web-server --release --local-engine=host_debug_unopt
66+
```
67+
68+
```
69+
felt test --integration-tests-only
70+
```
71+
72+
4. The golden will be under `engine/src/flutter/lib/web_ui/.dart_tool/goldens/engine/web/` directory, you should create a PR for that file and merge it to `flutter/goldens`.
73+
74+
5. Get the commit no and replace the `revision` in this file: `engine/src/flutter/lib/web_ui/dev/goldens_lock.yaml`
75+
76+
6. Don't forget to rechange the flag to switch goldens from update mode to comparison mode.
77+
78+
79+
```
80+
export UPDATE_GOLDENS=false
81+
```
82+
83+
7. Screenshot tests should work after this.

0 commit comments

Comments
 (0)