Missing package running jest

Hi,

I have jest referenced as a dev dependency and as part of my job I am updating packages. I have output node-modules folder content, and jest is there, still, the unit tests step fails due to a missing package error (the error: missing script: /home/circleci/ci-root/node_modules/jest/bin/jest)

Please help me here, going around this for some time now :frowning:
My config.yml

version: 2
jobs:
checkout:
docker:
- image: circleci/node:11.10
working_directory: ~/ci-root
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum “package.json” }}
- run:
name: Install Dependencies
command: npm install
- save_cache:
key: dependency-cache-{{ checksum “package.json” }}
paths:
- ./node_modules
- persist_to_workspace:
root: ~/
paths:
- ci-root
test:
docker:
- image: circleci/node:11.10
working_directory: ~/ci-root
steps:
- attach_workspace:
at: ~/
- run:
name: Install Dependencies
command: npm install
- run: # run tests
name: Install unit test framework
command: npm add --save-dev jest-junit
- run:
name: Run unit tests
command: npm run ~/ci-root/node_modules/jest/bin/jest --ci --runInBand --reporters=default --reporters=jest-junit
environment:
JEST_JUNIT_OUTPUT: “test-results/jest/results.xml”
- store_test_results:
path: test-results
workflows:
version: 2
Continuos Integration:
jobs:
- checkout
- test:
requires:
- checkout

Can you try updating this to dependency-cache-{{ checksum “package-lock.json” }} and push a fresh commit?

I’ve done it but still it did not fixed the error.
I’ve also changed the config.yml into a simpler version but no luck… Getting really out of options :frowning:

I’ve executed a step with ls command and it shows that jest.js exists on the folder

Simpler config.yml

version: 2
jobs:
build:
docker:
- image: circleci/node:11.10
working_directory: ~/ci-root
steps:
- checkout
- run:
name: Install Dependencies
command: npm install
- run:
name: Run unit tests
command: npm run ~/ci-root/node_modules/jest/bin/jest --ci --runInBand --reporters=default --reporters=jest-junit
environment:
JEST_JUNIT_OUTPUT: “test-results/jest/results.xml”
- store_test_results:
path: test-results

Try adding this as a script in your package.json instead as

"test:ci":"jest --ci --runInBand --reporters=default --reporters=jest-junit"

Then call in it config.yml as command: npm run test:ci

Let me know how that works

1 Like

Fantastic!!! This one works…
Tks so much

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.