I do a bunch of automation tests in Cypress. My project CI/CD is on Gitlab. I need to have a possibility to set up environment variable in Gitlab->Pipelines with the list of specific tests which I would like to run ("Test1, Test2"). I added the following to the index.js:
beforeEach(function() {
const testFilter = Cypress.env('TEST_FILTER');
if (!testFilter) {
return;
}
const testName = Cypress.mocha.getRunner().test.fullTitle();
cy.log("beforeEach1");
if (!testName.includes(testFilter)) {
cy.log("beforeEach2");
this.skip();
}
})
Then I updated my .gitlab-ci.yml with:
- TEST_FILTER: sampleTest.feature
And finally I have :
"cy:open": "cypress open",
"cy:filter:implicit": "set CYPRESS_TEST_FILTER=Implicit & cypress open",
However it doesn't work and when I run pipeline and add variable there on Gitlab (TEST_FILTER) I get this error:
Pipeline cannot be run.
Undefined error (01GDMNJ755F2J576MWPPX5Y9QQ)
Could you please help me to understand what I'm doing wrong?