【问题标题】:Cypress and Docker - Can't run because no spec files were found赛普拉斯和 Docker - 无法运行,因为找不到规范文件
【发布时间】:2019-01-03 23:00:15
【问题描述】:

我正在尝试在 docker 容器中运行 cypress 测试。我已经简化了设置,因此我可以尝试运行一个简单的容器实例并执行一些测试。

我正在使用 docker-compose

version: '2.1'
services:
  e2e:
    image: test/e2e:v1
    command: ["./node_modules/.bin/cypress", "run", "--spec", "integration/mobile/all.js"]
    build:
      context: .
      dockerfile: Dockerfile-cypress
    container_name: cypress
    network_mode: host

还有我的 Dockerfile-cypress

FROM cypress/browsers:chrome69

RUN mkdir /usr/src/app
WORKDIR /usr/src/app

RUN npm install cypress@3.1.0

COPY cypress /usr/src/app/cypress
COPY cypress.json /usr/src/app/cypress

RUN ./node_modules/.bin/cypress verify

当我在构建图像后运行 docker-compose up 时,我看到了

cypress | name_to_handle_at on /dev: Operation not permitted
cypress | Can't run because no spec files were found.
cypress |
cypress | We searched for any files matching this glob pattern:
cypress |
cypress | integration/mobile/all-control.js
cypress exited with code 1

我已验证我的 cypress 文件和文件夹已被复制,并且我可以验证我的测试文件是否存在。我已经坚持了一段时间,我不确定除了放弃还能做什么。

任何指导表示赞赏。

【问题讨论】:

    标签: docker-compose cypress


    【解决方案1】:

    原来赛普拉斯会自动检查/cypress/integration 文件夹。将我所有的柏树文件移动到这个文件夹中就可以了。

    【讨论】:

    • /cypress/integration 中移动文件使其正常工作
    【解决方案2】:

    问题:在您的自动化套件中找不到赛普拉斯规格文件。

    解决方案:赛普拉斯测试文件默认位于cypress/integration,但可以配置到其他目录。 在此文件夹中,按部分插入您的套件:

    例如:

     - cypress/integration/billing-scenarios-suite
     - cypress/integration/user-management-suite
     - cypress/integration/proccesses-and-handlers-suite
    

    我假设这些套件目录包含子目录(代表一些微逻辑),因此您需要递归运行它以收集所有文件:

    cypress run --spec \
    cypress/integration/<your-suite>/**/* , \
    cypress/integration/<your-suite>/**/**/*
    

    如果您在 docker 上的 cypress 中运行,请验证 cypress 卷是否包含测试并在 volume 部分(在 Dockerfile / docker-compose.yml 文件上)上的容器中映射和安装并正确运行:

    docker exec -it <container-id> cypress run --spec \
    cypress/integration/<your-suite>/**/* , \
    cypress/integration/<your-suite>/**/**/*
    

    【讨论】:

      猜你喜欢
      • 2021-05-31
      • 2021-11-04
      • 2020-12-23
      • 1970-01-01
      • 2021-10-13
      • 2022-09-30
      • 1970-01-01
      • 2022-11-10
      • 1970-01-01
      相关资源
      最近更新 更多