Skip to content
Latchkey

Vitest "No test suite found in file" in CI

Vitest loaded a file that matched your include pattern but found no registered tests inside it. The file ran without throwing, yet defined zero test/it cases.

What this error means

A run fails (or warns to error under --passWithNoTests=false) naming a specific file with "No test suite found". The file exists and imports cleanly, but contributes no tests.

node
Error: No test suite found in file /work/repo/src/utils.test.ts

Common causes

The include glob caught a non-test file

A broad pattern like **/*.ts or **/*.spec.* matched a helper or fixture file that has no test() calls. Vitest still tries to treat it as a suite.

Tests are gated behind a condition that was false

The file wraps its tests in an if (process.env.X) or a describe.skipIf(...) that evaluates false in CI, so nothing registers.

A transform stripped the test bodies

A misconfigured plugin or define replacement removed or short-circuited the test calls before Vitest collected them.

How to fix it

Tighten the include / exclude globs

Restrict collection to real test files and exclude helpers so non-test modules are never loaded as suites.

vitest.config.ts
// vitest.config.ts
export default {
  test: {
    include: ['src/**/*.{test,spec}.{ts,tsx}'],
    exclude: ['**/__fixtures__/**', '**/*.helpers.ts'],
  },
};

Allow empty matches deliberately

If a file can legitimately register zero tests in CI, opt in to passing rather than failing the whole run.

  1. Add --passWithNoTests only when intentional, not as a blanket workaround.
  2. Prefer fixing the glob so the empty file is never collected.
Terminal
vitest run --passWithNoTests

How to prevent it

  • Name test files with a clear suffix and include only that suffix.
  • Keep fixtures and helpers in directories excluded from collection.
  • Avoid wrapping entire test files in environment conditionals.

Related guides

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