我正在尝试在Travis CI中与我的Rails应用程序一起运行笑话测试。这就是Travis CI日志中弹出的内容。
$ 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.
这是我的.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
这是我的package.json>脚本和devDependencies部分
"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": [
它在yarn test
上失败。当我调试作业并一步一步地重新运行步骤时,它将成功,并且可以成功找到并运行jest
。我还尝试过清除存储库的缓存。
我在设置中缺少什么吗?
答案 0 :(得分:0)
我知道了,令人讨厌的步骤是:
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
bundle exec rake assets:precompile
编译Webpack捆绑软件以进行生产并删除devDependencies。因此,到达script
步骤时,它再也找不到jest
。短期解决方案是删除assets:precompile
中的before_script
。长远来说将是对资产预编译本身进行单独的工作测试。