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 thetestscriptnpm test -- --ci- pass CI flagsCI=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-junitIn 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=truedisables watch mode in many runners.- Emit JUnit XML for CI dashboards.
- A failing test exits non-zero and fails the job.