Jenkins -在Docker中运行Cypress测试



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

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

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

在<<p> strong> 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

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

我做错了什么?

嗯,我发现我忘了在Dockerfile中复制cypress文件夹到docker映像。现在它解决了所有问题:)

相关内容

  • 没有找到相关文章

最新更新