Running yarn test - jest: not found

I’m trying to run jest tests alongside my rails application in Travis CI. This is what pops up in the Travis CI logs.

$ yarn test
yarn run v1.9.4
$ jest
/bin/sh: jest: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Here’s my .travis.yml

sudo: required
services:
  - docker
  - redis-server
language: ruby
cache:
  bundler: true
  directories:
    - node_modules
  yarn: true
addons:
  postgresql: "9.6"
  chrome: stable
rvm:
  - 2.5.1
before_script:
  - cp config/database.yml{.sample,}
  - bundle exec rake db:create db:test:prepare assets:precompile
install:
  - bundle install
  - nvm install node
  - node -v
  - npm i -g yarn
  - yarn
script:
  - yarn test
  - bundle exec rake test

Here’s my package.json > scripts and devDependencies section

  "scripts": { "test": "jest" },
  "devDependencies": {
    "@vue/test-utils": "^1.0.0-beta.25",
    "babel-jest": "^23.6.0",
    "babel-preset-es2015": "^6.24.1",
    "eslint": "^5.5.0",
    "eslint-plugin-jest": "^21.22.0",
    "eslint-plugin-vue": "^4.7.1",
    "jest": "^23.6.0",
    "jest-canvas-mock": "^1.1.0",
    "stylelint": "^9.5.0",
    "stylelint-config-standard": "^18.2.0",
    "vue-jest": "^2.6.0",
    "webpack-dev-server": "2.11.2"
  },
  "jest": {
    "roots": [

It fails on yarn test . When I debug the job and re-run the steps one-by-one it succeeds and it can find and run jest successfully.

Am I missing something on my setup? I also posted this on Stackoverflow, looking to find some direction and where to head next

Okay I’ve solved it! The problem was bundle exec rake asset:precompile wipes out yarn install with a build that doesn’t include dev dependencies.

Hi - I’m having the same issue. Could you describe what you did to fix it?