From 8c351f813b776c1423d701077ba6ec197687f6e9 Mon Sep 17 00:00:00 2001 From: Yu / Midori Date: Sat, 29 Jun 2024 17:32:18 +0900 Subject: [PATCH] Setup golden test --- .gitignore | 3 +++ .vscode/launch.json | 17 +++++++++++++++++ dart_test.yaml | 2 ++ test/flutter_test_config.dart | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 dart_test.yaml create mode 100644 test/flutter_test_config.dart diff --git a/.gitignore b/.gitignore index d557e4b..95bce14 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,6 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release + +# golden_toolkit +**/failures/*.png \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..8f8bd57 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Golden", + "request": "launch", + "type": "dart", + "codeLens": { + "for": ["run-test", "run-test-file"] + }, + "args": ["--update-goldens"] + } + ] + } \ No newline at end of file diff --git a/dart_test.yaml b/dart_test.yaml new file mode 100644 index 0000000..f01b955 --- /dev/null +++ b/dart_test.yaml @@ -0,0 +1,2 @@ +tags: + golden: diff --git a/test/flutter_test_config.dart b/test/flutter_test_config.dart new file mode 100644 index 0000000..8679a31 --- /dev/null +++ b/test/flutter_test_config.dart @@ -0,0 +1,19 @@ +import 'dart:async'; +import 'package:golden_toolkit/golden_toolkit.dart'; + +/// Used for golden tests to load the app fonts before running the tests. +/// ref: https://pub.dev/packages/golden_toolkit +Future testExecutable(FutureOr Function() testMain) async => + GoldenToolkit.runWithConfiguration( + () async { + await loadAppFonts(); + return testMain(); + }, + config: GoldenToolkitConfiguration( + enableRealShadows: true, + defaultDevices: const [ + Device.phone, + Device.iphone11, + ], + ), + );