Skip to content
Latchkey

elm-test "Compilation failed" in CI

elm-test compiles your test modules and everything they import before running anything. A compile error in any reachable module stops the run with "Compilation failed" and zero tests executed.

What this error means

elm-test prints "Compilation failed while attempting to build ..." followed by the underlying Elm compiler error (NAMING ERROR, TYPE MISMATCH, MODULE NOT FOUND), and exits non-zero.

elm-test
Compilation failed while attempting to build .../tests/Example.elm

-- TYPE MISMATCH ------------------------------------------- tests/Example.elm

The 1st argument to `equal` is not what I expect:

Common causes

A test module does not compile

A test references a renamed value or passes the wrong type, so the compiler rejects it before any test runs.

A source module the tests import is broken

elm-test compiles imported source modules too; a build error in app code surfaces as a test compilation failure.

How to fix it

Fix the reported compiler error

  1. Read the Elm error block printed under "Compilation failed".
  2. Resolve it the same way you would for elm make (naming, type, or module).
  3. Re-run elm-test to confirm the suite compiles and runs.
Terminal
npx elm-test

Compile sources first to localize

Run elm make on the app entry point to separate app build errors from test-only ones before running elm-test.

Terminal
npx elm make src/Main.elm --output=/dev/null
npx elm-test

How to prevent it

  • Run elm-test locally before pushing so test compile errors surface early.
  • Keep test imports in sync when app modules change names or types.
  • Treat the suite as a build gate, since it will not run with any compile error.

Frequently asked questions

What causes "elm-test "Compilation failed""?
A test references a renamed value or passes the wrong type, so the compiler rejects it before any test runs.
How do I fix elm-test "Compilation failed"?
Fix the reported compiler error

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card