Claude Code Won't Run Your Tests? Real Fixes

Published Aug 6, 2026

Three real causes cover almost every case — the exact command, the environment it runs in, and how the request itself was phrased.

Cause 1 — most common

It Doesn't Know the Exact Test Command

Without a documented command, it has to guess — npm test, pytest, a custom script — and a wrong guess looks like "it won't run tests" when really it just ran the wrong thing or nothing at all.

Fix: document the real test command in CLAUDE.md once, instead of repeating it every session. See CLAUDE.md best practices for what belongs there.
Cause 2

Environment Mismatch

Tests that pass on your machine can fail or not run at all in a different working directory, without a required environment variable, or with a dependency that's installed globally on your machine but undocumented in the project.

Fix: document real environment requirements (not just the command) in CLAUDE.md — required env vars, working directory assumptions, setup steps.
Cause 3

A Permission Check on an Unusual Test Runner

Standard test commands are typically pre-approved, but a test runner that shells out to something unusual can trigger a real permission check that looks like a refusal to run tests at all.

Fix: rule this out separately — see permission denied, real causes before assuming it's a command or environment problem.

New to Claude Code? Start With the Basics

The free guide covers the permission model and a first real workflow — good CLAUDE.md habits from the start.

Get the Free Guide →

Frequently Asked Questions

Should I just tell it the exact test command every time?

No — document it once in CLAUDE.md instead. Repeating it every session is a sign the command belongs in project configuration, not in the prompt.

Why would tests pass for me but not for Claude Code?

Usually an environment difference — a different working directory, a missing environment variable, or a dependency installed globally on your machine but not documented anywhere in the project.

Is this a permission issue?

Sometimes — running a test suite is often pre-approved, but a test runner that shells out to something unusual can trigger a real permission check. Worth ruling out separately from a command or environment problem.