Skip to content
Latchkey

npm test in CI

npm test is the conventional entry point for your test suite.

Most CI configs call npm test. The CI environment variable changes some runners to non-interactive, non-watch mode automatically.

Common usage

  • npm test - run the test script
  • npm test -- --ci - pass CI flags
  • CI=true - many tools auto-detect this

Example in CI

Run tests with a JUnit reporter for the dashboard.

shell
CI=true npm test -- --reporters=default --reporters=jest-junit

In CI

Ensure your test command exits and does not start a watcher. Jest/Vitest watch is disabled when CI is set, but verify in your config.

Key takeaways

  • CI=true disables watch mode in many runners.
  • Emit JUnit XML for CI dashboards.
  • A failing test exits non-zero and fails the job.

Related guides

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