groupMethod method
Expression
groupMethod({})
Generates a group method that runs the Golden tests.
Implementation
Expression groupMethod({
required String widgetName,
required String? builder,
required String goldenName,
required String? lightTheme,
required String? darkTheme,
required List<String> dimensions,
}) {
return refer('group').newInstance([
literalString('$widgetName golden tests'),
Method(
(m) => m
..body = Block.of(
[
...dimensions.map(
(dimension) {
return testWidgetMethod(
widgetName: widgetName,
builder: builder,
goldenName: goldenName,
theme: lightTheme,
darkTheme: false,
dimension: dimension,
).statement;
},
),
if (darkTheme != null)
...dimensions.map(
(dimension) {
return testWidgetMethod(
widgetName: widgetName,
builder: builder,
goldenName: goldenName,
theme: darkTheme,
darkTheme: true,
dimension: dimension,
).statement;
},
),
],
),
).closure,
]);
}