Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we expect html report for the accessibility issues #49

Open
rishichenna opened this issue Jul 22, 2020 · 3 comments
Open

Can we expect html report for the accessibility issues #49

rishichenna opened this issue Jul 22, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@rishichenna
Copy link

No description provided.

@sapegin
Copy link
Member

sapegin commented Oct 26, 2020

Why do you want to have an HTML specifically? How are you planning to use it?

@sapegin sapegin added the enhancement New feature or request label Oct 26, 2020
@boochamoocha
Copy link

Need the same - json and html reports after all tests running.

Maybe you could give me a clue about how to collect vulnerabilities and then use it?

@sapegin
Copy link
Member

sapegin commented Nov 10, 2020

For now you can use violationCallback.

cy.checkA11y(subject, null, violations => cy.task('reportA11y', violations), skipFailures)

And then do whatever you want with them in your cypress/plugins/index.js file. For example, I pint a summary to the terminal:

import { sortBy } from 'lodash';

const a11yViolations = {};

function appendA11yViolations(violations) {
  for (const { id, impact, description, nodes } of violations) {
    if (!a11yViolations[id]) {
      a11yViolations[id] = { impact, description, count: 0 };
    }
    a11yViolations[id].count += nodes.length;
  }
}

function printA11ySummary() {
  const orders = { critical: 1000, serious: 2000, moderate: 3000, minor: 4000 };
  const sorted = sortBy(a11yViolations, ({ impact, count }) => orders[impact] - count);
  console.table(sorted);
}

export default (on, config) => {
  on('task', {
    reportA11y(violations) {
      appendA11yViolations(violations);
      return null;
    },
    afterAll() {
      printA11ySummary();
      return null;
    },
  });

  return config;
};

And add this to your cypress/support/index.js:

// Send an event we can subscribe to inside a plugin
after(() => {
  cy.task('afterAll');
});

I want to include such functionality in the next major release. JSON is definitely a good option but I'm not so sure about HTML — it's a lot more work on templates and styling so I need more details on how folks are going to use it.

@sapegin sapegin mentioned this issue Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants