badeball / cypress-cucumber-preprocessor

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

Cypress-cucumber-preprocessor with Cypress-split #1189

Closed ludo550 closed 2 months ago

ludo550 commented 2 months ago

Hi @badeball ,

Hope you are doing great. Our team is trying to use the latest version of cypress cucumber implementation with cypress-split , However, we are having issues making it happen. All tests run in a single container as opposed to the vanilla cypress splitting it's specs up successfully. I have come to find out that addCucumberPreprocessorPlugin and cypress-split cannot be used together as cypress cucumber requires the former. Using the latter before the former doesn't do anything and using the former before the latter throws an error that the preprocessor events are being overwritten. Can you please help on this issue or advise for the same? image

Here's my setupNodeEvents function that causes the issue above. Removal of cypressSplit(on, config) resolves the issue but makes it unusable with cypressSplit.


async setupNodeEvents(on, config) {
      await addCucumberPreprocessorPlugin(on, config, {
        omitBeforeRunHandler: true,
        omitAfterRunHandler: true,
        omitBeforeSpecHandler: true,
        omitAfterSpecHandler: true,
        omitAfterScreenshotHandler: true,
      });
      on('before:run', async (details) => {
        console.log('override before:run');
        await beforeRunHandler(config);
      });
      on("before:spec", async (spec) => {
        await beforeSpecHandler(config, spec);
      });
      on("after:run", async (results) => {
        console.log(results);
      });
      on('after:spec', (spec, results) => {
        afterSpecHandler(config, spec, results);
        if (results && results.stats.failures === 0 && results.video) {
          return del.del(results.video, { force: true })
        }
      });
      on('before:browser:launch', (browser, launchOptions) => {
          if (browser.name === 'chrome') {
            launchOptions.args.push('--js-flags=--expose-gc');
          }
          return launchOptions;
      });
      on(
        "file:preprocessor",
        createBundler({
          plugins: [esbuild.esbuild.createEsbuildPlugin(config)],
        })
      );
      cypressSplit(on, config);
      return config;
    }
ludo550 commented 2 months ago

I have some things to confirm. I will reopen, once my doubts are confirmed

badeball commented 2 months ago

https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/event-handlers.md

ludo550 commented 1 month ago

Thank you @badeball !