Elm Test Runner CLI

0.19.1-revision17 · active · verified Sun Apr 19

elm-test is the official Node.js command-line interface (CLI) for running test suites written with the `elm-explorations/test` Elm package. As of April 2026, the current stable version is `0.19.1-revision17`, with frequent patch-level releases (revisions) to address compatibility issues, bug fixes, and Node.js environment support. It functions by compiling Elm tests and executing them within a Node.js environment. A key differentiator is its tight coupling with specific versions of the `elm-explorations/test` Elm package; users must ensure compatibility between the CLI and the Elm testing library to avoid unexpected behavior, such as missing test distribution diagrams or compilation errors. It provides features like watch mode, selective test execution by file or glob, and various reporting formats.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically install, initialize, and run `elm-test` from a Node.js script, covering basic test execution patterns.

import { exec } from 'child_process';
import { promisify } from 'util';

const execPromise = promisify(exec);

async function runElmTests() {
  try {
    console.log("1. Installing elm-test as a dev dependency...");
    // Using npm install locally ensures `npx elm-test` works reliably.
    await execPromise('npm install --save-dev elm-test');
    console.log("elm-test installed.");

    console.log("2. Initializing Elm test project (creates tests/Example.elm and configures elm.json)...");
    // The --yes flag answers 'y' to prompts, making it non-interactive.
    const initOutput = await execPromise('npx elm-test init --yes');
    console.log(initOutput.stdout);

    console.log("3. Running all tests in the project...");
    const runOutput = await execPromise('npx elm-test');
    console.log(runOutput.stdout);

    console.log("4. Running tests in a specific file (e.g., tests/Example.elm)...");
    const specificFileOutput = await execPromise('npx elm-test tests/Example.elm');
    console.log(specificFileOutput.stdout);

    console.log("Quickstart complete. Note: Watch mode (npx elm-test --watch) runs indefinitely.");
  } catch (error) {
    console.error(`Error during elm-test quickstart: ${error.message}`);
    console.error(`Stderr: ${error.stderr}`);
  }
}

runElmTests();

view raw JSON →