Jenkins - 运行 Cypress 在 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 运行:
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 图像。现在它解决了一切:)
在 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 运行:
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 图像。现在它解决了一切:)