lpelypenko / axe-html-reporter

Creates easy to read HTML file from axe-core® accessibility results object
MIT License
30 stars 22 forks source link

Generate axe-core HTML report only with critical violations #28

Open sureshdubey opened 4 months ago

sureshdubey commented 4 months ago

How to generate axe-core HTML report only with critical violations? In the HTML report, I want to see only critical and major and dont need minor violation (impact). Is it possible?

meduzen commented 4 months ago

I think you have two ways to do it: either you only test for critical violations, this way they are the only categories that will be reported, either you test other things but you clean/filter all results.{something} arrays before passing results to the reporter.

Here’s a simplified version of an implementation of mine in a project using Playwright, where it should be easy to filter the results before passing them to the reporter (make sure to check the whole implementation) :

    const results = await testAccessibilty(page)

    // new lines for you
    const isCritical = result => result.impact == 'critical'
    results.violations = results.violations.filter(isCritical)
    results.passes = results.passes.filter(isCritical)
    results.incomplete = results.incomplete.filter(isCritical)
    results.inapplicable = results.inapplicable.filter(isCritical)

    const htmlReport = createHtmlReport(results) // hand-made helper