npm test

built-in
0.0% Savings
0 Commands
0 Tokens saved
2 Tests

Install

tokf install 8a53b75db2d9681cd2711ed651cb4cd7a470b657fc8c77f68a6aeabd13705535
Safety checks passed

Filter definition

command = ["npm test", "pnpm test", "yarn test"]

# Parent fallback — used when no variant matches
strip_ansi = true
skip = [
  "^> ",
  "^\\s*npm (warn|notice|WARN|verbose|info|timing|error|ERR)",
  "^\\s*WARN\\s",
  "^\\s*ERR!",
  "^\\s*yarn run",
  "^\\s*\\$\\s",
]

[on_success]
tail = 15

[on_failure]
tail = 20

[[variant]]
name = "vitest"
detect.files = ["vitest.config.ts", "vitest.config.js", "vitest.config.mts"]
filter = "npm/test-vitest"

[[variant]]
name = "jest"
detect.files = ["jest.config.js", "jest.config.ts", "jest.config.json"]
filter = "npm/test-jest"

Examples

fallback failure shows tail, strips npm noise ~92 tokens → ~44 tokens (52% saved)
Raw output
> myapp@1.0.0 test
> node run-tests.js
npm warn deprecated some-package@1.0.0: use other-package instead

FAIL tests/app.test.js
  Test suite failed to run

    SyntaxError: Unexpected token

      at Parser.pp$4.raise (node_modules/acorn/dist/acorn.js:3024:15)

Error: Test failed
npm ERR! Test failed.  See above for more details.
npm verbose exit 1
npm verbose code 1
Filtered output

FAIL tests/app.test.js
  Test suite failed to run

    SyntaxError: Unexpected token

      at Parser.pp$4.raise (node_modules/acorn/dist/acorn.js:3024:15)

Error: Test failed
fallback success strips npm noise ~100 tokens → ~27 tokens (73% saved)
Raw output
> myapp@1.0.0 test
> node run-tests.js
npm warn deprecated some-package@1.0.0: use other-package instead
npm WARN deprecated another@2.0.0: moved to @scope/another
npm verbose cli /usr/bin/node /usr/lib/node_modules/npm/bin/npm-cli.js
npm info using npm@10.9.2

running 5 tests...
test 1 passed
test 2 passed
test 3 passed
test 4 passed
test 5 passed

all tests passed
npm verbose exit 0
npm info ok
Filtered output

running 5 tests...
test 1 passed
test 2 passed
test 3 passed
test 4 passed
test 5 passed

all tests passed
Warning: Community filters are third-party code. Review the filter definition above before installing it in production environments.
Browse all filters