How to use the axe-core.run function in axe-core

To help you get started, we’ve selected a few axe-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mimecuvalo / helloworld / client / internal / A11y.js View on Github external
function runAudit() {
    console.log('[a11y]: running accessibility audit...');
    axe.run(
      document,
      {
        rules: {
          // This is a very annoying property of color-contrast that causes the page to scroll on page load.
          // We disable it here. This 'options' structure is insane btw. wtf.
          'color-contrast': { checks: { 'color-contrast': { options: { noScroll: true } } } },
        },
      },
      (err, results) => {
        if (err) throw err;
        console.log('[a11y]:', results);
        setErrorCount(results.violations.length);
        setResults(results);
      }
    );
  }
github coveo / search-ui / accessibilityTest / AccessibilityErrorReport.ts View on Github external
it('should be accessible when a query triggers an error', async done => {
      // !BOOM
      addQueryFilter('$qre()');
      buildErrortReportElement();
      await afterQueryError();
      const axeResults = await axe.run(getRoot());
      expect(axeResults).toBeAccessible();
      done();
    });
github storybookjs / storybook / addons / a11y / src / index.ts View on Github external
progress = progress.then(() => {
    axe.reset();
    if (config) {
      axe.configure(config);
    }
    return axe
      .run(
        element || getElement(),
        options ||
          ({
            restoreScroll: true,
          } as RunOptions) // cast to RunOptions is necessary because axe types are not up to date
      )
      .then(report)
      .catch(error => addons.getChannel().emit(EVENTS.ERROR, String(error)));
  });
};
github rpearce / react-medium-image-zoom / __tests__ / Uncontrolled.js View on Github external
new Promise((resolve, reject) => {
    axe.run(html, {}, (err, { violations }) => {
      if (err) {
        reject(err)
      }
      if (violations.length > 0) {
        reject(violations)
      }
      resolve(true)
    })
  })
github coveo / search-ui / accessibilityTest / AccessibilityTab.ts View on Github external
it('should be accessible when configured as a div', async done => {
      const tab = $$('div', {
        className: Component.computeCssClassName(Tab),
        'data-caption': 'All Content',
        'data-id': 'All'
      });

      getTabSection().appendChild(tab.el);

      await afterQuerySuccess();
      const axeResults = await axe.run(getRoot());
      expect(axeResults).toBeAccessible();
      done();
    });
github coveo / search-ui / accessibilityTest / AccessibilityOmnibox.ts View on Github external
it('should be accessible', async done => {
      const omniboxElement = getOmniboxElement();
      getSearchSection().appendChild(omniboxElement.el);
      await afterQuerySuccess();
      const axeResults = await axe.run(getRoot());
      expect(axeResults).toBeAccessible();
      done();
    });
github storybookjs / storybook / addons / a11y / src / components / WrapStory.js View on Github external
runA11yCheck() {
    const { channel, axeOptions } = this.props;
    const wrapper = findDOMNode(this);

    if (wrapper !== null) {
      axe.reset();
      axe.configure(axeOptions);
      axe.run(wrapper).then(results => channel.emit(CHECK_EVENT_ID, results), logger.error);
    }
  }
github coveo / search-ui / accessibilityTest / AccessibilityResultPreviewsManager.ts View on Github external
it('should be accessible', async done => {
      await afterQuerySuccess();
      await focusOnFirstSuggestion();
      await waitForPreviews();
      const axeResults = await axe.run(getRoot());
      expect(axeResults).toBeAccessible();
      done();
    });
  });
github coveo / search-ui / accessibilityTest / AccessibilityCardOverlay.ts View on Github external
it('should be accessible when opened', async done => {
      const cardOverlayElement = getOverlayElement();

      testResultElement(cardOverlayElement.el);
      await afterQuerySuccess();
      getOverlayInstance().openOverlay();
      await afterDelay(1000);
      const axeResults = await axe.run(getRoot());
      expect(axeResults).toBeAccessible();
      done();
    });