expectNoCriticalFailures static method
Asserts that projectPath has no critical accessibility failures.
Throws a TestFailure with a human-readable summary if any rule is below its critical threshold. Useful as a one-liner smoke test:
test('no critical a11y failures', () async {
await EthosTestHelper.expectNoCriticalFailures('lib/');
});
Implementation
static Future<void> expectNoCriticalFailures(
String projectPath, {
String? configPath,
}) async {
final report = await analyzeProject(projectPath, configPath: configPath);
final critical = report.coverage.values.where((c) => c.isCritical).toList();
if (critical.isEmpty) {
return;
}
final lines = critical.map((c) {
final pct = c.percentage.toStringAsFixed(1);
return ' • ${c.title} ($pct% — below ${c.ruleId} threshold)';
}).join('\n');
throw TestFailure(
'Ethos found ${critical.length} critical accessibility failure(s):\n'
'$lines\n\n'
'Run `ethos -p $projectPath` for full details.',
);
}