Cypress: WebPack编译错误:尽管已安装所有必需的模块

huangapple go评论45阅读模式
英文:

Cypress :WebPack Compilation Error: Despite of having all the required modules

问题

以下是您要翻译的内容:

[![在此输入图像描述](https://i.stack.imgur.com/5uxXC.png)](https://i.stack.imgur.com/5uxXC.png)

我正在尝试在项目中设置和安装 Cypress,我已安装 Cypress 版本 14.12.0
Node 版本:18.11.0
"@badeball/cypress-cucumber-preprocessor": "^18.0.0",
"@cypress/webpack-preprocessor": "^5.17.1",

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

module.exports = defineConfig({
  e2e: {
 
    specPattern: 'cypress/e2e/features/*.feature',
    stepDefinitions: "cypress/e2e/common/*.js",
    "fixturesFolder": "cypress/fixtures",
    supportFile: 'cypress/support/e2e.js',
    setupNodeEvents(on, config) {
      // 在此处实现节点事件监听器
    },

  },
});

希望这对您有所帮助。如果您有任何其他问题或需要进一步的翻译,请随时提问。

英文:

Cypress: WebPack编译错误:尽管已安装所有必需的模块

I am trying to setup and install cypress in a project and i have installed cypress version 14.12.0
Node Version : 18.11.0
"@badeball/cypress-cucumber-preprocessor": "^18.0.0",
"@cypress/webpack-preprocessor": "^5.17.1",

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

module.exports = defineConfig({
e2e: {

specPattern: 'cypress/e2e/features/*.feature',
stepDefinitions: "cypress/e2e/common/*.js",
"fixturesFolder": "cypress/fixtures",
supportFile: 'cypress/support/e2e.js',
setupNodeEvents(on, config) {
  // implement node event listeners here
},

},
});

答案1

得分: 2

这是修正后的代码部分,对于CJS:

const { defineConfig } = require('cypress')
const createBundler = require('@bahmutov/cypress-esbuild-preprocessor')
const preprocessor = require('@bahmutov/cypress-cucumber-preprocessor')
const createEsBuildPlugin = require('@bahmutov/cypress-cucumber-preprocessor/esbuild')

module.exports = defineConfig({
  e2e: {
    specPattern: 'cypress/e2e/features/*.feature',
    stepDefinitions: 'cypress/e2e/common/*.js',    // 这可能是一个问题!
    fixturesFolder: 'cypress/fixtures',
    supportFile: 'cypress/support/e2e.js',
    async setupNodeEvents(on, config) {
      await preprocessor.addCucumberPreprocessorPlugin(on, config);
      on(
        "file:preprocessor",
        createBundler({
          plugins: [createEsBuildPlugin.default(config)],
        })
      );
      return config;
    },
  },
})
英文:

It looks like you didn't finish reading the instructions - some of the modules you have imported are not used at all, and you misspelled one of them.

Here is the correct version, for CJS:

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')

module.exports = defineConfig({
  e2e: {
    specPattern: 'cypress/e2e/features/*.feature',
    stepDefinitions: 'cypress/e2e/common/*.js',    // this may be a problem!
    fixturesFolder: 'cypress/fixtures',
    supportFile: 'cypress/support/e2e.js',
    async  setupNodeEvents(on, config) {
      await preprocessor.addCucumberPreprocessorPlugin(on, config);
      on(
        "file:preprocessor",
        createBundler({
          plugins: [createEsBuildPlugin.default(config)],
        })
      );
      return config;
    },
  },
})

huangapple
  • 本文由 发表于 2023年6月15日 14:21:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76479636.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定