run

npm test

Shortcut for `npm run test` — runs the `test` script from package.json. Aliases: `npm t`, `npm tst`.

npm test [-- <args>]

Common flags

Flag Purpose
-- Forward flags to the test runner (Jest, Vitest, Mocha)
--workspaces (-ws) Run test in every workspace that defines one
--if-present No-op when the script is missing (useful in monorepos)
--silent Suppress npm's framing output

Examples

npm test

Run the project's test script

npm t -- --coverage

Pass --coverage through to Jest/Vitest

npm test -ws --if-present

Run tests across every workspace that has one

Gotcha

Like `start`, `npm test` is sugar for `npm run test`, so `pretest`/`posttest` scripts still execute. Runner-specific flags MUST come after `--` or npm will try to interpret them.

Related commands

← All npm commands · npm vs pnpm vs Yarn · Fix Node OOM