【问题标题】:Cypress Github action throwing an error during run赛普拉斯 Github 操作在运行期间引发错误
【发布时间】:2022-08-22 22:12:02
【问题描述】:

我正在尝试设置一个简单的赛普拉斯 Github 操作来测试被推送到每个分支的代码以及在合并之前的代码。但我似乎每次都会出错。不知道是不是和cypress-io/github-action@v2使用的node版本有关系,不管我怎么做,一直抛出这个错误。以下是我项目中的相关文件。

包.json

{
  \"name\": \"crossa-frontend\",
  \"version\": \"0.1.0\",
  \"private\": true,
  \"dependencies\": {
    \"@stitches/react\": \"^1.2.8\",
    \"@testing-library/jest-dom\": \"^5.14.1\",
    \"@testing-library/react\": \"^13.0.0\",
    \"@testing-library/user-event\": \"^13.2.1\",
    \"@types/jest\": \"^27.0.1\",
    \"@types/node\": \"^16.7.13\",
    \"@types/react\": \"^18.0.0\",
    \"@types/react-dom\": \"^18.0.0\",
    \"apisauce\": \"^2.1.5\",
    \"axios\": \"^0.27.2\",
    \"axios-retry\": \"^3.2.5\",
    \"react\": \"^17.0.2\",
    \"react-dom\": \"^17.0.2\",
    \"react-scripts\": \"5.0.0\",
    \"typescript\": \"^4.4.2\",
    \"web-vitals\": \"^2.1.0\"
  },
  \"scripts\": {
    \"docker:build-image-staging\": \"docker-compose build --no-cache staging\",
    \"docker:build-image-prod\": \"docker-compose build --no-cache prod\",
    \"docker:staging\": \"docker-compose up staging\",
    \"docker:prod\": \"docker-compose up prod\",
    \"start\": \"react-scripts start\",
    \"build\": \"react-scripts build\",
    \"test\": \"react-scripts test\",
    \"eject\": \"react-scripts eject\",
    \"storybook\": \"start-storybook -p 6006 -s public\",
    \"build-storybook\": \"build-storybook -s public\",
    \"cypress:open\": \"cypress open\",
    \"cypress:run\": \"cypress run\"
  },
  \"eslintConfig\": {
    \"extends\": [
      \"react-app\",
      \"react-app/jest\",
      \"plugin:cypress/recommended\"
    ],
    \"overrides\": [
      {
        \"files\": [
          \"**/*.stories.*\"
        ],
        \"rules\": {
          \"import/no-anonymous-default-export\": \"off\"
        }
      }
    ]
  },
  \"browserslist\": {
    \"production\": [
      \">0.2%\",
      \"not dead\",
      \"not op_mini all\"
    ],
    \"development\": [
      \"last 1 chrome version\",
      \"last 1 firefox version\",
      \"last 1 safari version\"
    ]
  },
  \"devDependencies\": {
    \"@storybook/addon-a11y\": \"^6.4.19\",
    \"@storybook/addon-actions\": \"^6.4.19\",
    \"@storybook/addon-essentials\": \"^6.4.19\",
    \"@storybook/addon-interactions\": \"^6.4.19\",
    \"@storybook/addon-links\": \"^6.4.19\",
    \"@storybook/builder-webpack5\": \"^6.4.19\",
    \"@storybook/manager-webpack5\": \"^6.4.19\",
    \"@storybook/node-logger\": \"^6.4.19\",
    \"@storybook/preset-create-react-app\": \"^4.1.0\",
    \"@storybook/react\": \"^6.4.19\",
    \"@storybook/testing-library\": \"0.0.9\",
    \"cypress\": \"^10.1.0\",
    \"eslint-plugin-cypress\": \"^2.12.1\",
    \"webpack\": \"^5.70.0\"
  }
}

柏树.yml

name: Cypress Tests
on:
  push:
    branches:
      - dev
      - staging
      - prod
    pull_request:
jobs:
  cypress-run:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Cypress run
        uses: cypress-io/github-action@v2
        with:
          build: npm run build
          start: npm start

这是 Github Actions 上的错误

如果有人使用最新的反应版本做到了这一点,请帮助我。

  • Annnnnd...哪个错误? :p
  • @dbuchet 抱歉,已添加。它完全让我忘记了。
  • 你有@storybook/* 的最新版本吗?
  • @dbuchet 最新版本的 react 有问题,所以我不得不恢复到可以工作的版本。

标签: reactjs testing cypress github-actions


【解决方案1】:

尝试将“--legacy-peer-deps”添加到您的运行中:

    name: Cypress Tests
on:
  push:
    branches:
      - dev
      - staging
      - prod
    pull_request:
jobs:
  cypress-run:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Install dependencies ?
        run: npm ci --legacy-peer-deps
      - name: Show Cypress information ℹ️
        run: npx cypress info
      - name: Verify Cypress can run ?‍♂️
        run: npx cypress verify
      - name: Cypress run
        uses: cypress-io/github-action@v2
        with:
          build: npm run build
          start: npm start

【讨论】:

  • 我在您的示例代码中的任何地方都没有看到“--legacy-peer-deps”
  • @Vendetta 谢谢。我已经编辑了我的示例代码
猜你喜欢
  • 2021-10-23
  • 1970-01-01
  • 1970-01-01
  • 2022-01-19
  • 2021-12-05
  • 2022-09-30
  • 2023-01-26
  • 2020-09-13
  • 1970-01-01
相关资源
最近更新 更多