英文:
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) {
// 在此处实现节点事件监听器
},
},
});
希望这对您有所帮助。如果您有任何其他问题或需要进一步的翻译,请随时提问。
英文:
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;
},
},
})
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论