badeball / cypress-cucumber-preprocessor

Run cucumber/gherkin-syntaxed specs with Cypress
MIT License
1.31k stars 144 forks source link

Only the first feature is executed in mode inprivate, when executing from command line #1208

Closed xyuste closed 2 weeks ago

xyuste commented 2 weeks ago

Hi, I am working with the following versions:

  "devDependencies": {
    "cypress": "^13.12.0",
    "typescript": "^5.5.2"
  },
  "dependencies": {
    "@badeball/cypress-cucumber-preprocessor": "^20.1.0",
    "@bahmutov/cypress-esbuild-preprocessor": "^2.2.1",
    "cypress-xpath": "^2.0.1"
  }

I have one test project with 2 features, when I try to execute my test with: npx cypress run --browser edge --headed

Only the first feature is executed in the "inprivate" mode, the second one is executed in normal mode.

My file tsconfig.json:

const { defineConfig } = require("cypress");
import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
import createEsbuildPlugin from "@badeball/cypress-cucumber-preprocessor/esbuild";

module.exports = defineConfig({
  e2e: {
    specPattern: "**/*.feature",
    async setupNodeEvents(
      on: Cypress.PluginEvents,
      config: Cypress.PluginConfigOptions
    ): Promise<Cypress.PluginConfigOptions> {
      await addCucumberPreprocessorPlugin(on, config);
      on(
        "file:preprocessor",
        createBundler({
          plugins: [createEsbuildPlugin(config)],
        })
      );
      on('before:browser:launch', (browser = {}, launchOptions) => {
        // `args` is an array of all the arguments that will
        // be passed to browsers when it launches
        console.log(launchOptions.args) // print all current args
        if (browser.name === 'edge') {
          // open in incognito
          launchOptions.args.push('--inprivate')
        }
        if (browser.family === 'chromium' && browser.name !== 'electron') {
          launchOptions.args.push("--incognito");                
        }
          // whatever you return here becomes the launchOptions
        return launchOptions
      })
      return config;
    },
  },
  experimentalModifyObstructiveThirdPartyCode: true,
  chromeWebSecurity: true,
});

Do you know what is the problem?? Thanks

badeball commented 2 weeks ago

Do you know what is the problem??

No, I don't. However, I doubt this pertains to the preprocessor, hence closing.