我是一名自动化工程师,试图在现有的React应用程序中配置Cypress测试,但我一直收到以下错误消息:
这是我的Github项目链接: https://github.com/francislainy/hello-talk-web/tree/cucumber 谢谢。
更新
我在项目根目录下创建了 webpack.config.js 文件,但仍然出现相同的错误。
./cypress/e2e/googleSearch.feature 1:16
Module parse failed: Unexpected token (1:16)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> Feature: Google Search
我的功能文件位于: /Users/francislainycampos/IdeaProjects/hello-talk-web/cypress/e2e/googleSearch.feature
我的步骤文件位于: /Users/francislainycampos/IdeaProjects/hello-talk-web/cypress/e2e/spec/googleSearch.spec.js
我的插件/index.js 文件含有以下内容:
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
on('file:preprocessor', cucumber())
}
而我的 package.json 文件有这些版本:
"devDependencies": {
"cypress": "^12.11.0",
"cypress-cucumber-preprocessor": "^4.3.1",
"@cypress/webpack-preprocessor": "^5.17.1",
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
}
我的cypress.config.js文件包含:
const {defineConfig} = require("cypress");
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
specPattern: "/Users/francislainycampos/IdeaProjects/hello-talk-web/cypress/e2e/googleSearch.feature",
// integrationFolder: "cypress/e2e",
supportFile: "cypress/support/commands.js",
},
});
这是我的Github项目链接: https://github.com/francislainy/hello-talk-web/tree/cucumber 谢谢。
更新
我在项目根目录下创建了 webpack.config.js 文件,但仍然出现相同的错误。
module.exports = {
module: {
rules: [
{
test: /\.feature$/,
use: [
{
loader: 'cypress-cucumber-webpack-preprocessor/loader',
},
],
},
],
},
};
cypress-cucumber-preprocessor
? - Wandrillenpm install --save-dev cypress cypress-cucumber-preprocessor
命令安装了Cypress Cucumber处理器。 - Francislainy Camposcypress-cucumber-preprocessor
不再更新。该软件包已迁移到github.com/badeball/cypress-cucumber-preprocessor
。请使用它。 - Wandrille