testNyPageLoading function
Test a NyStatefulWidget's loading state.
Example:
testNyPageLoading(
'HomePage shows loading state',
build: () => HomePage(),
);
Implementation
void testNyPageLoading(
String description, {
required Widget Function() build,
bool skip = false,
}) {
testWidgets(description, (tester) async {
NyWidgetTest.configure();
await tester.pumpWidget(
_NyTestWrapper(theme: NyWidgetTest.simpleTestTheme, child: build()),
);
await tester.pump();
// Verify some form of loading indicator is present
final hasLoader = find
.byType(CircularProgressIndicator)
.evaluate()
.isNotEmpty;
final hasSkeletonizer = find
.byType(skel.Skeletonizer)
.evaluate()
.isNotEmpty;
// At least one loading indicator should be present
// (unless the page has LoadingStyle.none())
expect(hasLoader || hasSkeletonizer, isTrue);
}, skip: skip);
}