jest command not found or not installed

The `jest` command could not be found.

jest-command-not-found high confidence test node

Matched signals

  • jest: command not found
  • path.*\.bin/jest

jest command not found or not installed

What this failure means

The jest command could not be found. Jest is either not installed as a dependency, not in the PATH, or the wrong shell was used to run it.

Symptoms

Faultline looks for one or more of these log fragments:

jest: command not found
path.*\.bin/jest

Diagnosis

Jest is typically installed locally as a dev dependency and accessed through npm run test or npx jest. Common causes:

  • Jest is not listed in package.json as a devDependency.
  • npm install or npm ci was not run before the test step, or it failed silently.
  • The script is running in a different shell that does not have the PATH updated.
  • Jest is installed locally but the script tries to use the global jest command.
  • The test step runs before the install step in CI.

The error typically appears as jest: command not found or jest is not installed.

Fix steps

  1. Verify Jest is in package.json:

    grep jest package.json
    
  2. If missing, add it as a dev dependency:

    npm install --save-dev jest
    
  3. Ensure npm install completes before running tests:

    npm install
    npm test
    
  4. Use npm run test or npx jest instead of calling jest directly:

    npm run test    # Uses local jest from node_modules
    npx jest        # Also uses local jest
    jest            # May not work if jest is not in PATH
    
  5. Check that the CI job runs the test step after the install step:

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: npm install     # Must run BEFORE test
      - run: npm test        # Now jest is available
    

Validation

  • npm install completes without errors.
  • npm run test or npx jest executes tests successfully.
  • npm ls jest shows jest is installed in node_modules.

Why it matters

Missing test runners block the entire test pipeline. Test failures cannot be diagnosed if the test command itself fails to run.

Prevention

  • Always run npm install (or npm ci) before test steps in CI.
  • Use npm run test instead of calling commands directly.
  • Document the test command in package.json and README.md.
  • Commit package-lock.json to ensure consistent installs.

Try it locally

npm install
npm run test
npm ls jest
npm ls jest
npm test

How Faultline detects it

Use faultline explain jest-command-not-found to see the full playbook.

faultline analyze build.log
faultline explain jest-command-not-found

Generated from playbooks/bundled/log/test/jest-command-not-found.yaml. Do not edit directly.

Try it on your own failed log

$ faultline analyze failed.log
Want this across every CI run? Faultline Teams tracks recurring failures across all your repos and surfaces patterns in a shared dashboard.