CircleCI +赛普拉斯配置

时间:2018-05-07 21:04:41

标签: testing cypress circleci-2.0

您好我在与赛普拉斯一起设置CircleCi时遇到问题。

我包含了所有必需依赖项的docker镜像,但它仍然无效。我尝试了大约40种不同的配置而没有任何积极的结果。请检查下面屏幕截图中附带的配置和输出。

enter image description here

version: 2
jobs:
  build:
    docker:
      - image: circleci/node:9.2.0

      - image: circleci/mongo:3.4.4
      - image: cypress/base:8

working_directory: ~/repo

steps:
  - checkout

  - restore_cache:
      keys:
      - v1-dependencies-{{ checksum "package.json" }}
      - v1-dependencies-

  - run: yarn install

  - save_cache:
      paths:
        - node_modules
      key: v1-dependencies-{{ checksum "package.json" }}

  - run: yarn test   // THIS COMMAND RUNS UNIT TESTS - and it is working ok

  - run: yarn run dev & $(npm bin)/cypress run // THIS ONE IS FAILING

我也意识到如果我删除node / mongo的图像并且只运行e2e测试它正在工作。当我尝试使用三个docker镜像运行单元和e2e测试时,会出现问题。

2 个答案:

答案 0 :(得分:2)

我尝试了bkcura's answer,但没有成功,并且仍然出现相同的错误。

所以我尝试使用新的Circle功能(球)来混合两个球:

它有效?

这是我的 config.yml

  "data": {
    "pupilReports": {
      "new": {
        "date": "0001-01-01",
        "pupilReportTemplateId": 0,
        "pupilReportTemplate": {
          "id": 99,
          "name": "KS3 Science",
          "sortedPupilAttributeCollections": [
            {
              "sortOrder": 1,
              "pupilAttributeCollection": {
                "id": 1,
                "name": "Attainment",
                "sortedPupilAttributes": [
                  {
                    "sortOrder": 1,
                    "pupilAttribute": {
                      "id": 1,
                      "name": "Physics",
                      "type": "Boolean"
                    }
                  },
                  {
                    "sortOrder": 2,
                    "pupilAttribute": {
                      "id": 1,
                      "name": "Physics",
                      "type": "Boolean"
                    }
                  }
                ]
              }
            },
            {
              "sortOrder": 2,
              "pupilAttributeCollection": {
                "id": 1,
                "name": "Attainment",
                "sortedPupilAttributes": [
                  {
                    "sortOrder": 1,
                    "pupilAttribute": {
                      "id": 1,
                      "name": "Physics",
                      "type": "Boolean"
                    }
                  },
                  {
                    "sortOrder": 1,
                    "pupilAttribute": {
                      "id": 1,
                      "name": "Physics",
                      "type": "Boolean"
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    }
  }

带有演示的回购:https://github.com/jeanbauer/create-react-app-cypress-circle-ci

注意:可能效率不高,所以如果您看到任何改进,请向我发送问题here

答案 1 :(得分:0)

在此处查看文档:{​​{3}}

您无需缓存node_modules,而不必缓存~/.cache

steps:
  - checkout
  - restore_cache:
      keys:
        - v1-deps-{{ .Branch }}-{{ checksum "package.json" }}
        - v1-deps-{{ .Branch }}
        - v1-deps
  - run:
      name: Install Dependencies
      command: yarn install --frozen-lockfile
  - save_cache:
      key: v1-deps-{{ .Branch }}-{{ checksum "package.json" }}
      paths:

为什么?

Cypress在项目文件夹之外安装了一个特定于平台的预构建二进制文件,该文件在~/.cache/Cypress中约为200mb,需要花一些时间下载,因此您应该对其进行缓存。

它也仅安装在postInstall上,如果您缓存node_modules则不会安装,因此错误消息=)