I need feature1.feature to run three times as displayed in cypress.config.js . But while running
npx cypress run --config-file cypress.config.js ` the feature1.feature is running only once. Is there any way I can Update the config file to run all feature1.feature.
const { defineConfig } = require("cypress");
const cucumber = require("cypress-cucumber-preprocessor").default;
module.exports = defineConfig({
env: {
url: "https://dev-abc.com/",
},
e2e: {
setupNodeEvents(on, config) {
on('file:preprocessor', cucumber())
},
specPattern:
[
"**/feature1.feature",
"**/feature2.feature",
"**/feature3.feature",
"**/feature1.feature",
"**/feature4.feature",
"**/feature1.feature"
],
testIsolation: false
},
defaultCommandTimeout: 10000,
videosFolder: 'cypress/reports/folder1/mochawesome/videos',
screenshotsFolder: 'cypress/reports/folder1/mochawesome/screenshots',
reporter: "mochawesome",
sample: "value",
reporterOptions: {
reportDir: 'cypress/reports/folder1/mochawesome/logs',
overwrite: false,
html: false,
json: true,
},
});
I guess because
specPattern
is a pattern, when Cypress evaluates it you only getfeature1
once in the (internal) list of specs to run.You could try a comma-separated list at the CLI
see if that invokes it twice.
Slightly less cumbersome is to create an "index" test
feature-list.feature
This works for vanilla js tests, maybe also for cucumber.
I have to add, it seems a bit strange to be repeating tests in a test run, unless you are coupling them - which generally is a bad practice.
If this is what you are doing, I suggest you forget this question and instead ask how to re-use parts of a test in other tests.