In Jenkins I have a docker container, in which I want to run my Cypress tests (cucumber preprocessor).
All feature files are placed in myrepo/cypress/integration/features/**/.feature
That means I have multiple subfolders under feature folder and in each subfolder are placed the feature files. (e.g. myrepo/cypress/integration/features/admin/testadmin.feature)
In package.json I have defined for scripts test:
"test": "node_modules\\.bin\\cypress run --spec \"cypress/integration/features/**/*.feature\""
and in jenkins trying to run it via:
sh 'docker exec image1 npm run test'
But it can't find the feature files.
Then I tried to specify the path directly in the command and changing to cypress run:
sh 'docker exec image1 ./node_modules/.bin/cypress run --spec "cypress/integration/features/**/*.feature" '
But I have this error:
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
I also tried it withou quotemarks:
sh 'docker exec testrepo ./node_modules/.bin/cypress run --spec cypress/integration/features/**/*.feature'
Then it says:
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
So it seems, my first solution with quote marks is correct, and also it knows about the feature files if they are listed there, but still says can't find them.
So what am I doing wrong?
CodePudding user response:
Well, I've found out that I forgot to COPY the cypress folder to docker image in Dockerfile. Now it solved everything :)