Closed nyck33 closed 3 years ago
@nyck33 in looking at your code, I think it is less about the package and more about those imports.
I think if you switch them to be fully qualified package imports it will work.
relative imports don't usually cross the lib/ folder boundary.
@coreysprague
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:coupon_app/views/views_layer.dart';
import 'package:coupon_app/dummy_data/dummy_user.dart' as dummy;
import 'package:coupon_app/models/data_layer.dart';
final User mockUser = User(userId: -100, name: 'mock', email: "mock@mock.com");
final User copyUser = dummy.dummyUser.copyWith(userId: -100);
void main() {
testGoldens('FirstScreen has DeathStar', (WidgetTester tester) async {
await tester.pumpWidget(FirstScreen(user: mockUser));
await screenMatchesGolden(tester, 'firstscreen_deathstar');
});
}
but I get:
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
Expected: one widget whose rasterized image matches golden image
"goldens/firstscreen_deathstar.png"
Actual: _FirstFinder:<exactly one widget with widget matching predicate (Closure: (Widget) =>
bool) (ignoring all but first) (ignoring offstage widgets): FirstScreen(state:
_FirstScreenState#a1740)>
Which: Could not be compared against non-existent file: "goldens/firstscreen_deathstar.png"
but the documentation says: The output of this test will be this golden file: weather_accessibility.png:
I know with the golden test that comes with Flutter, I have to produce the images first before running the test but your documentation makes it sound like the ground-truth image is produced on-the-fly.
What am I missing?
@nyck33 I think you'd have to run the tests with the special flag :
flutter test --update-goldens --tags=golden
(see https://github.com/eBay/flutter_glove_box/tree/master/packages/golden_toolkit#testgoldens )
This will generate the golden files that do not exist yet.
If you use VSCode, you can also configure it so a little Golden
link appears next to each test : https://github.com/eBay/flutter_glove_box/tree/master/packages/golden_toolkit#configure-vs-code
@tsimbalar Thanks so much for taking time out of your busy day for this. I'll give it a try.
@nyck33 I think the readme has some information with screenshots : https://github.com/eBay/flutter_glove_box/tree/master/packages/golden_toolkit#configure-vs-code
Please see here: https://github.com/dart-lang/sdk/issues/47327#issuecomment-931528909 I removed your package and the test I wrote for it and everything is fine. Why would it cause that?