Speed Up Your Tests

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard

Techniques for reducing the time Axe Watcher adds to your end-to-end test suite

Not for use with personal data

Integrating Axe Watcher into your end-to-end test suite adds time because Watcher analyzes each page your tests visit. If that overhead becomes a problem, the techniques below let you reduce it without giving up coverage you care about.

Exclude Pages You Don't Need to Test

If your test suite visits pages you don't need to test for accessibility (login pages, third-party pages, admin dashboards, checkout flows owned by another team), you can skip them entirely using excludeUrlPatterns. Skipping entire pages is the most effective way to reduce testing time.

JavaScript or TypeScript:

axe: {
  excludeUrlPatterns: [ 'https://example.com/login*', 'https://example.com/admin/**' ]
}

Java:

AxeWatcherOptions options = new AxeWatcherOptions();
options.setExcludeUrlPatterns(new String[] {
    "https://example.com/login*",
    "https://example.com/admin/**"
});

See Exclude URLs from Analysis for pattern syntax and matching examples.

Limit Analysis to Specific Page Sections

Instead of analyzing the entire page, use runContext to focus on the section your test exercises. For example, if a test only covers the checkout form, there is no need to analyze the navigation, footer, or sidebar.

JavaScript or TypeScript:

axe: {
  runContext: {
    include: '.checkout-form',
    exclude: '.site-navigation'
  }
}

Java:

AxeRunContext context = new AxeRunContext()
    .setInclude(Arrays.asList(".checkout-form"))
    .setExclude(Arrays.asList(".site-navigation"));

AxeWatcherOptions options = new AxeWatcherOptions();
options.setRunContext(context);
important

When you specify elements to include via runContext, Axe Watcher analyzes only the matching elements. If a selector doesn't match anything on the page, nothing will be analyzed, and no page state will be captured. Double-check your selectors before deploying this configuration.

See (JavaScript/TypeScript) runContext or (Java) AxeRunContext for more information.

Disable Expensive Rules

Some axe-core rules are computationally expensive. The color-contrast rule, for example, requires the browser to compute the rendered color of every visible text element on the page, which can add significant time on content-heavy pages.

You can disable specific rules using runOptions.rules:

JavaScript or TypeScript:

axe: {
  runOptions: {
    rules: {
      'color-contrast': { enabled: false }
    }
  }
}

Java:

Map<String, AxeRuleOptions> rules = new HashMap<>();
rules.put("color-contrast", new AxeRuleOptions().setEnabled(false));

AxeRunOptions runOptions = new AxeRunOptions();
runOptions.setRules(rules);

AxeWatcherOptions options = new AxeWatcherOptions();
options.setRunOptions(runOptions);
important

Disabling a rule means issues caught by that rule won't appear in your results. Consider running disabled rules in a separate, dedicated test suite rather than skipping them permanently.

Using runOptions.rules (or runOnly) generates a warning because those settings can conflict with your organization's global Axe configuration. See Using runOptions with runOnly or Rules.

See (JavaScript/TypeScript) runOptions or (Java) AxeRunOptions for more information.

Use Manual Mode to Control Which Tests Analyze Pages

By default, Watcher automatically analyzes every page your tests visit. If most of your test suite visits pages you don't need to check, you can turn off automatic analysis globally and enable it only in the tests that need it.

JavaScript or TypeScript:

axe: {
  autoAnalyze: false
}

Java:

AxeWatcherOptions options = new AxeWatcherOptions();
options.setAutoAnalyze(false);

With automatic analysis disabled, you call analyze() explicitly where you need a result, and use start() / stop() to bracket sections of your test suite where you want automatic analysis to resume.

See Control Your Scans for full instructions and examples.

Run Tests in Parallel

If your testing infrastructure supports parallel execution, running your test suite with multiple workers reduces total wall-clock time. Watcher supports parallel test runners; you only need to ensure each worker shares the same non-null buildID so their results are combined rather than overwritten.

See Running Tests in Parallel for setup instructions.

Summary

Technique Best for Trade-off
Exclude pages Pages your team doesn't own or doesn't need to test Important pages could be mistakenly missed
Limit page sections Large pages where only part is relevant to your test Issues outside the selected sections are not found
Disable expensive rules Teams find that certain expensive rules don't apply to their situation Those rules don't run in this test suite
Manual mode Test suites that visit many pages irrelevant to accessibility testing Requires explicit analyze() / start() / stop() calls in test code
Parallel testing Teams with CI infrastructure that supports parallel workers Requires coordinating buildID across workers