assertSeoHealthy function

void assertSeoHealthy(
  1. SeoAuditReport report, {
  2. SeoSeverity threshold = SeoSeverity.error,
})

Throws SeoAuditFailure unless report passes at threshold.

The one call a test needs:

test('the site has no SEO errors', () async {
  assertSeoHealthy(
    await auditSeoRoutes(routes: seoRoutes, siteBase: siteBase),
  );
});

It exists because the obvious hand-written alternative is easy to get wrong in a way that always passes — this package shipped a doc comment recommending expect(report.describe(), isNot(contains( '[error]'))), which never failed, because describe() marks errors with x. A helper that owns the comparison cannot drift from the format it is comparing against.

Implementation

void assertSeoHealthy(
  SeoAuditReport report, {
  SeoSeverity threshold = SeoSeverity.error,
}) {
  if (!report.passes(threshold: threshold)) {
    throw SeoAuditFailure(report, threshold);
  }
}