Skip to content
Latchkey

Deno test nonzero exit (failing tests) in CI

deno test exits nonzero when any test fails, throws, or a step errors. CI treats the nonzero exit as a failed job and prints the failing test names and assertions.

What this error means

The step ends with "test result: FAILED. N passed; M failed" and "error: Test failed" and the job exits with code 1.

deno
running 2 tests from ./main_test.ts
adds numbers ... FAILED
  error: AssertionError: Values are not equal.
    [Diff] Actual / Expected
    -   3
    +   4
test result: FAILED. 1 passed; 1 failed

Common causes

A real assertion or thrown error in a test

The test logic failed an assertion or threw, which deno test reports as a failure and a nonzero exit.

Environment differences between local and CI

Missing permissions, env vars, or a different Deno version make a test that passes locally fail on the runner.

How to fix it

Reproduce and fix the failing test

  1. Read the failing test name and assertion diff.
  2. Run that test locally with the same permissions CI uses.
  3. Fix the code or test and re-run.
Terminal
deno test -A --filter "adds numbers"

Grant the permissions tests need in CI

Ensure the test command grants the same read/write/net/env access the tests require so they behave as they do locally.

.github/workflows/ci.yml
- run: deno test --allow-read --allow-env

How to prevent it

  • Run the full test suite with CI permissions locally before pushing.
  • Pin the Deno version so behavior matches CI.
  • Provide required env and permissions in the test step.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →