最近开始使用Cypress
和@cypress/vue
,我的组件测试通过以下脚本在本地环境中运行良好:
"cy:运行ct":"柏树运行ct";
我的项目由Amplify console
托管,我想在每次部署中运行它们(组件测试而不是e2e测试(,所以尝试将yarn cy:run-ct
添加到amplify.yml
:
frontend:
phases:
preBuild:
commands:
- yarn install
- yarn test
- yarn cy:run-ct
这给了我一个错误CCD_ 6。
有人在Amplify控制台上成功run-ct
吗?还是还不支持?
如果能正常工作,Cyprus组件测试(yarn cy:run-ct
(可以在amplify.yml
的test.phases.test.commands部分运行,如下所示:
version: 1
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn run build
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*
test:
artifacts:
baseDirectory: cypress
configFilePath: '**/mochawesome.json'
files:
- '**/*.png'
- '**/*.mp4'
phases:
preTest:
commands:
- npm install
- npm install wait-on
- npm install pm2
- npm install mocha@5.2.0 mochawesome mochawesome-merge mochawesome-report-generator
- npx pm2 start npm -- start
- 'npx wait-on http://localhost:3000'
test:
commands:
- 'yarn cy:run-ct'
- 'npx cypress run --reporter mochawesome --reporter-options "reportDir=cypress/report/mochawesome-report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss"'
postTest:
commands:
- npx mochawesome-merge cypress/report/mochawesome-report/mochawesome*.json > cypress/report/mochawesome.json
- npx pm2 kill
现在所有的柏树组件测试和e2e测试都运行正常,如果任何测试失败,Amplify控制台将停止部署。
以下是我们的操作方法。我们使用NPM,但这并不重要。。。
test:
phases:
preTest:
commands:
- npm ci
- "npm start & npx wait-on http://localhost:3000"
test:
commands:
- "npm run e2e:amplify"
postTest:
commands:
- npx mochawesome-merge cypress/report/mochawesome-report/mochawesome*.json > cypress/report/mochawesome.json
artifacts:
baseDirectory: cypress
configFilePath: "**/mochawesome.json"
npm运行e2e:放大脚本。。。
"e2e:放大":"npx赛柏润--记者mochawesome--记者选项"reportDir=cyps/report/mochawesome report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HMMss";,