I am working in a nrwl nx workspace,, I have a cypress BDD cucumber project set up in it. I need to run cypress tests based on tags using nrwl.
Normally i would use cypress-tags command to do the same:
eg: "cypress run --env TAGS='@smoke' --browser chrome
"
I applied the same logic to an nx command.
eg: nx e2e myProject-e2e --tags=@reg
But the nx project is identifying all test cases in cypress, it does not take into consideration the test cases tagged with tag "@reg"
Can someone guide me if there is a provision in nrwl to run cypress tests based on tags
I had the same issue and got a workaround by using the ENV object from the NX configuration:
This way, I added the tags in the project.json
configuration file, in my case for running the smoke test and a regression test based on the tags filtering:
"smoke": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/explore-e2e/cypress.json",
"baseUrl": "<BASE_URL>",
"env": {
"TAGS": "@smoke"
}
},
"configurations": {
"staging": {
"baseUrl": "<STG_URL>"
},
"production": {
"baseUrl": "<PROD_URL>"
}
}
},
"regression": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/explore-e2e/cypress.json",
"baseUrl": "<BASE_URL>",
"env": {
"TAGS": "@regression"
}
},
"configurations": {
"staging": {
"baseUrl": "<STG_URL>"
},
"production": {
"baseUrl": "<PROD_URL>"
}
}
}
With this, you can now start tagging your scenarios and running it with:
nx e2e myProject-e2e:smoke --TAGS=@smoke
(In my case I'm using: yarn nx run
instead)