繁体   English   中英

Jenkins - 在 Docker 中运行赛普拉斯测试

[英]Jenkins - running Cypress tests in Docker

在 Jenkins 中,我有一个 docker 容器,我想在其中运行我的 Cypress 测试(黄瓜预处理器)。

所有功能文件都放在myrepo/cypress/integration/features/**/.feature

这意味着我在功能文件夹下有多个子文件夹,每个子文件夹中都放置了功能文件。 (例如 myrepo/cypress/integration/features/admin/testadmin.feature)

package.json 中,我为脚本测试定义了:

"test": "node_modules\\.bin\\cypress run --spec \"cypress/integration/features/**/*.feature\""

并在 jenkins 中尝试通过以下方式运行它:

sh 'docker exec image1 npm run test'

但它找不到功能文件。

然后我尝试直接在命令中指定路径并更改为 cypress run:

sh 'docker exec image1 ./node_modules/.bin/cypress run --spec "cypress/integration/features/**/*.feature" '

但我有这个错误:

Can't run because no spec files were found.

We searched for any files matching this glob pattern:

cypress/integration/features/**/*.feature

Relative to the project root folder: /myrepo

我也尝试过不带引号:

sh 'docker exec testrepo ./node_modules/.bin/cypress run --spec cypress/integration/features/**/*.feature'

然后它说:

   Warning: It looks like you're passing --spec a space-separated list of arguments:
    
    "cypress/integration/features/admin/testadmin.feature cypress/integration/features/admin/anothertest.feature ... etc.
    
    This will work, but it's not recommended.
      
    The most common cause of this warning is using an unescaped glob pattern. If you are
    trying to pass a glob pattern, escape it using quotes...

We searched for any files matching this glob pattern:

cypress/integration/features/admin/testadmin.feature, cypress/integration/features/admin/anothertest.feature

Relative to the project root folder:/myrepo

看来,我的第一个带引号的解决方案是正确的,而且它也知道功能文件是否列在那里,但仍然说找不到它们。

那我做错了什么?

好吧,我发现我忘记将 cypress 文件夹复制到 Dockerfile 中的 docker 图像。现在它解决了所有问题:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM