badeball / cypress-cucumber-preprocessor

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

Import createEsbuildPlugin not working #1209

Closed leey0nz closed 3 months ago

leey0nz commented 3 months ago

Current behavior

Import createEsbuildPlugin not working

Desired behavior

Please help me support import createEsbuildPlugin

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

export default defineConfig({
  e2e: {
    specPattern: '**/*.feature',
    async setupNodeEvents(
      on: Cypress.PluginEvents,
      config: Cypress.PluginConfigOptions
    ): Promise<Cypress.PluginConfigOptions> {
      // This is required for the preprocessor to be able to generate JSON reports after each run, and more,
      await addCucumberPreprocessorPlugin(on, config);

      on(
        'file:preprocessor',
        createBundler({
          plugins: [createEsbuildPlugin(config)],
        })
      );
      on('after:run', async (results) => {
        if (results) {
          await afterRunHandler(config);
          fs.mkdirSync('cypress/reports/data-result');
          await fs.writeFile(
            'cypress/reports/data-result/results.json',
            JSON.stringify(results)
          );
        }
      });
      // on('after:run', (results) => {
      //   if (results) {
      //     fs.mkdirSync("cypress/reports1");
      //     // fs.writeFile("cypress/reports1/hoang-results.json", JSON.stringify(results));
      //   }
      // })

      // Make sure to return the config object as it might have been modified by the plugin.
      return config;
    },
  },
});

Versions

Ảnh màn hình 2024-07-05 lúc 20 40 35 Ảnh màn hình 2024-07-05 lúc 21 10 49
badeball commented 3 months ago

This is answered in the FAQ.

For future issues, you need to adhere to the guidelines for reporting issues and fill out the issue template properly.