我試圖添加一個 github 操作,它應該使用 cypress 測驗我的應用程式。
這是我的作業流檔案的樣子:
name: Cypress Tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./client
steps:
- name: Checkout
uses: actions/checkout@v2
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Test
run: |
ls
cat package.json
- name: Cypress run
uses: cypress-io/[email protected]
with:
build: npm run build
start: npm start
- name: Test
run: ls
測驗步驟包含cat package.json顯示 package.json 檔案,如下所示:
{
"name": "client",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
},
"dependencies": {
"@reduxjs/toolkit": "^1.6.1",
"axios": "^0.21.4",
"framer-motion": "^4.1.17",
"next": "11.1.2",
"phosphor-react": "^1.3.1",
"qs": "^6.10.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-leaflet": "^3.2.1",
"react-redux": "^7.2.5",
"uuid": "^8.3.2",
"cypress": "^8.6.0"
},
"devDependencies": {
"autoprefixer": "^10.3.4",
"cypress": "^8.6.0",
"eslint": "7.32.0",
"eslint-config-next": "11.1.2",
"postcss": "^8.3.6",
"tailwindcss": "^2.2.15"
}
}
如您所見,有一個構建腳本,但是當作業流運行時,它會引發此錯誤:
build app command "npm run build"
current working directory "/home/runner/work/mlc/mlc"
/opt/hostedtoolcache/node/14.18.0/x64/bin/npm run build
npm ERR! missing script: build
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-10-17T11_04_01_715Z-debug.log
Error: The process '/opt/hostedtoolcache/node/14.18.0/x64/bin/npm' failed with exit code 1
我不知道為什么會發生這種情況,因為 package.json 證明存在構建腳本。
uj5u.com熱心網友回復:
我有同樣的錯誤,答案很簡單,但是我還沒有在單個檔案中找到它。
您必須添加:working-directory: client在with:Cypress 內部運行后,如下所示:
——
name: Cypress Tests
on: [push]
jobs: cypress-run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v2
with:
working-directory: client
build: npm run build
start: npm start
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/322674.html
標籤:反应 测试 下一个.js 柏 github-actions
上一篇:java.lang.ClassNotFoundException:無法找到資料源:org.apache.bahir.sql.streaming.mqtt.MQTTStreamSinkProvider。
下一篇:如何模擬函式的函式?
