0Pricing
Web Accessibility Academy · Lección

Integrar axe-core en pruebas de Playwright

Haga fallar la compilación cuando aparezcan regresiones de a11y.

Integrar axe-core en pruebas de Playwright es una lección gratuita de Web Accessibility Academy en CoddyKit. Esta es la lección 3 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Web Accessibility Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Web Accessibility Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

From Manual Scan to Automated Test

Clicking a browser extension is great for one page. To guard every page on every commit, you wire axe-core into your automated test suite.

Why Playwright

Playwright drives a real browser from code, so axe runs against the page exactly as users see it, including content rendered by JavaScript.

The Bridge Package

The axe-core/playwright package connects the two. Install it alongside Playwright so your tests can inject and run the axe engine.

npm install --save-dev @axe-core/playwright

Import the Builder

In your test file you import AxeBuilder. It is the helper that injects axe-core into the current page and collects the results for you.

import AxeBuilder from '@axe-core/playwright';

Navigate, Then Analyze

First let Playwright load the page, then call analyze on a fresh AxeBuilder to scan whatever is currently rendered in the browser.

await page.goto('/');
const results = await new AxeBuilder({ page }).analyze();

Assert Zero Violations

The result holds a violations array. A passing page has an empty array, so you assert its length is zero to fail the test on any issue.

expect(results.violations).toEqual([]);

A Complete Test Case

Put it together and you have a real accessibility test that runs in CI like any other Playwright spec.

test('home page has no a11y violations', async ({ page }) => {
  await page.goto('/');
  const results = await new AxeBuilder({ page }).analyze();
  expect(results.violations).toEqual([]);
});

Test After Interaction

The real power is scanning dynamic states. Open a modal or expand a menu first, then analyze, so axe checks the UI users actually trigger.

await page.getByRole('button', { name: 'Open menu' }).click();
const results = await new AxeBuilder({ page }).analyze();

Narrow the Scope

You can focus the scan on one region with include, which is handy when testing a single component without noise from the rest of the page.

new AxeBuilder({ page }).include('#signup-form').analyze();

Choose Your Rule Set

Use withTags to run only the rules tied to a standard, like the WCAG 2.1 AA criteria, so your test matches your conformance target.

new AxeBuilder({ page }).withTags(['wcag2a', 'wcag2aa']).analyze();

Remember the Ceiling

Green Playwright tests still only cover the automatable share of issues. They complement manual screen reader checks; they never replace them.

Quick Check

Recall how you make a test fail on accessibility problems.

Recap: a11y in Your Pipeline

AxeBuilder injects axe-core into a real browser, you analyze each state, and assert zero violations. Now accessibility regressions break the build automatically. ✅

Preguntas frecuentes

¿La lección «Integrar axe-core en pruebas de Playwright» es gratis?

Sí — el texto completo de «Integrar axe-core en pruebas de Playwright» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Web Accessibility Academy, actualiza a CoddyKit PRO. El curso de Web Accessibility Academy incluye 4 lecciones en total.

¿Qué aprenderé en «Integrar axe-core en pruebas de Playwright»?

Haga fallar la compilación cuando aparezcan regresiones de a11y. Practicas Web Accessibility Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Web Accessibility Academy?

No se requiere experiencia previa. Web Accessibility Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 3 de 4.

¿Cuánto tiempo toma la lección «Integrar axe-core en pruebas de Playwright»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Web Accessibility Academy?

Sí. Cada lección de Web Accessibility Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Lo que la automatización puede detectar y lo que no
  2. Análisis con axe DevTools y Lighthouse
  3. Integrar axe-core en pruebas de Playwright
  4. Linting y barreras de CI para la accesibilidad
← Volver a Web Accessibility Academy