I upgraded Cypress
from 9.5.2
to 10.3.0
and previously I was using cypress-cucumber-preprocessor
:4.3.1
now I upgrade it to @badeball/cypress-cucumber-preprocessor
:^11.4.0
.
Before the upgrade, I was using cypress-tags
for running the test using command
npx cypress-tags run --env TAGS="@regression" --browser chrome
but after the upgrade it's throwing me below error.
npm ERR! could not determine executable to run
Please find the sample feature below
Feature: Login Features
@regression
Scenario: Test sample login
Given I login to the website as "testUser"
Can someone help me to get an alternate option for running tests based on the tags with the latest Cypress and cucumber?
TLDR
Just remove cypress-tags
altogether, but a good enhancement is to add filterSpecs
and omitFiltered
options.
From this page Transfer of ownership
The
cypress-tags
has been removed and made redundant. Specs containing no matching scenarios are automatically filtered, provided thatfilterSpecs
is set to true.
So, if I run
npx cypress run --env tags="@regression"
I get results like
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ √ duckduckgo.feature 0ms - - - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ √ duckduckgo2.feature 00:04 1 1 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
√ All specs passed! 00:04 1 1 - - -
which has done the job (duckduckgo2.feature has the regression tag).
But it's better with these two config options
package.json
{
...
"devDependencies": {
"@badeball/cypress-cucumber-preprocessor": "^11.3.1",
"cypress": "^10.3.0",
},
"cypress-cucumber-preprocessor": {
"filterSpecs": true,
"omitFiltered": true
}
}
I now get
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ √ duckduckgo2.feature 00:04 1 1 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
√ All specs passed! 00:04 1 1 - - -
cypress.config.js
const { defineConfig } = require("cypress");
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor");
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
const createEsbuildPlugin = require("@badeball/cypress-cucumber-preprocessor/esbuild");
async function setupNodeEvents(on, config) {
await preprocessor.addCucumberPreprocessorPlugin(on, config);
on(
"file:preprocessor",
createBundler({
plugins: [createEsbuildPlugin.default(config)],
})
);
return config;
}
module.exports = defineConfig({
e2e: {
specPattern: "**/*.feature",
supportFile: false,
setupNodeEvents,
},
});