Getting Started

Prerequisites

Before you start using the Code Checker, you need to have a working browser automation testing setup. The Code Checker has been tested on some of the most common frameworks, but it should be possible to use it in any tool where a page is rendered in a browser. We currently provide guides for the following frameworks:

  • Playwright
  • Puppeteer
  • Selenium
  • Cypress

Module System

Alfa is distributed as ESM (ECMAScript Modules). Thus, projects using the old CJS (CommonJS) format (using require) for modules won't be able to use it directly. There are essentially four ways to handle that:

  1. Switch the full project to ESM. This is likely the most future-proof solution, but also the one requiring most work upfront. Hence it might not be the best solution for all projects but is probably a good solution for new projects. Check this quick overview of the required steps to get an idea of the required work.
  2. Use dynamic import(). That is, replace all
    import { Foo } from "@siteimprove/alfa-foo";
    with
    const { Foo } = await import("@siteimprove/alfa-foo");
    and move them inside the async function which is also calling Alfa. This is a quick solution but might be cumbersome to maintain.
  3. Use ESM files for the part of the project that uses Alfa. This is done easily by using the .mts or .mjs extension on the files. This is relatively quick but implies that the part of the project using Alfa will be isolated from the rest.
  4. Use an ESM-for-CJS loader such as the esm package. This solution has not been tested, but it should work.

Previous: IntroductionNext: Installation