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

Generate Report Off React Selector Violations #9

Open
alexmaddock opened this issue Apr 6, 2022 · 0 comments
Open

Generate Report Off React Selector Violations #9

alexmaddock opened this issue Apr 6, 2022 · 0 comments

Comments

@alexmaddock
Copy link

Is it possible to generate a report highlighting the react selector specifically as the point at which an Axe violation happens?

Have tried using elementRef: true to check if this helps, but encountering issues related to an error as such:

1) with cannot return DOM elements. Use Selector functions for this purpose.

The code I'm using is as follows:

import { axeCheck } from '@testcafe-community/axe';
import { createHtmlReport } from 'axe-html-reporter';
import { Selector } from 'testcafe';

export const Accessibility = {

  scanPage: async(t, pageName) => {

    const context = { exclude: Selector('select') };
    const options = { rules: { 'document-title': { enabled: false } }, elementRef: true };
    // Run axe check, not using wrapper function that throws error
    const { error, results } = await axeCheck(t, context, options); // "context" and "options" parameters are optional

    console.log(`error: ${error}`);

    // "results" constant contains full axe Results object (https://www.deque.com/axe/core-documentation/api-documentation/#results-object)
    await t.expect(error).eql(null, `axe check failed with an error: ${error}`);
    
    createHtmlReport({
      results,
      options: {
        projectKey: `"${pageName}"`,
        outputDir: 'reports/artifacts/' + pageName
      }
    });
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant