CircleCI Jest tests keep failing

circle.yml
#1

My Jest tests run locally, without any problems whatsoever. I can see them fail, and pass. However when i run my tests, through the CircleCI CI/CD pipeline, they always fail. I can install dependencies and run builds, without issue. The only test that fails to do anything is the one, for running my unit tests. My project is on GitHub.

Console error

#!/bin/bash -eo pipefail
npm test
npm info it worked if it ends with ok
npm info using npm@2.15.11
npm info using node@v4.8.2
npm info pretest jest-circle-test@1.0.0
npm info test jest-circle-test@1.0.0

jest-circle-test@1.0.0 test /home/circleci/project
jest

TypeError: blacklist.includes is not a function
at shouldSkipValidationForPath (/home/circleci/project/node_modules/jest/node_modules/jest-cli/node_modules/jest-validate/build/validate.js:42:17)
at _validate (/home/circleci/project/node_modules/jest/node_modules/jest-cli/node_modules/jest-validate/build/validate.js:93:8)
at validate (/home/circleci/project/node_modules/jest/node_modules/jest-cli/node_modules/jest-validate/build/validate.js:123:20)
at normalize (/home/circleci/project/node_modules/jest/node_modules/jest-cli/node_modules/jest-config/build/normalize.js:472:72)
at readConfig (/home/circleci/project/node_modules/jest/node_modules/jest-cli/node_modules/jest-config/build/index.js:184:68)
at projects.filter.hasDeprecationWarnings (/home/circleci/project/node_modules/jest/node_modules/jest-cli/build/cli/index.js:473:77)
at /home/circleci/project/node_modules/jest/node_modules/jest-cli/build/cli/index.js:251:23
at next (native)
at step (/home/circleci/project/node_modules/jest/node_modules/jest-cli/build/cli/index.js:206:30)
at /home/circleci/project/node_modules/jest/node_modules/jest-cli/build/cli/index.js:225:14
npm info jest-circle-test@1.0.0 Failed to exec test script
npm ERR! Test failed. See above for more details.
Exited with code 1

config.yml

version: 2
jobs:
  build:
docker: # use the docker executor type; machine and macos executors are also supported
  - image: circleci/node:4.8.2 # the primary container, where your job's commands are run
steps:
  - checkout # check out the code in the project directory
  - run: echo "npm installing" # run the `echo` command
  - run: npm install
  - run: npm build
  test:
docker: # use the docker executor type; machine and macos executors are also supported
  - image: circleci/node:4.8.2 # the primary container, where your job's commands are run
steps:
  - checkout # check out the code in the project directory
  - run: echo "Testing Code" #
  - run: npm install
  - run: npm test
workflows:
  version: 2
  build_test_and_lint:
jobs:
  - build
  - test
#2

I figured it out. FYI for anyone else who has this problem. It was the version of node i was using, node:4.8.2. Once i updated it to node:current the test script worked. So just make sure that you are running an up to date, stable release of node. https://circleci.com/docs/2.0/circleci-images/#nodejs

1 Like