谁能帮我让 Cucumber 与 Cypress 合作?绝对我能找到的每一个指南在设置中都有这个步骤:
X.
Add the relevant configurations to your Cypress environment files accordingly.
Under plugins/Index.JS file add the following:
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
on('file:preprocessor', cucumber())
}
但是,我的项目没有 cypress/plugins/index.js 文件。但是,它确实有一个 cypress/plugins/index.ts 文件。我认为 TypeScript 是 Cypress 的标准,而不是 JavaScript?
上面的代码在“require”(TS2591:找不到名称“require”)、“module”(TS2591:找不到名称“module”)和参数“on”和“config”上给出了错误。
显然,index.ts 文件是 index.js 一次,因为它仍然包含在文件中:
// This example plugins/index.js can be used to load plugins
但显然这里出了点问题。但是为什么显然“整个互联网”上没有其他人遇到过这个问题呢?(:-))
为了继续尝试,我跳过了这一部分——也是因为我读到了一些不再需要它的提示(虽然不确定)。
我还在项目 pom.xml 中添加了这个依赖项:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-cypress</artifactId>
<version>5.7.0</version>
</dependency>
然后进行 npm 安装、maven clean install、refresh 等,并在 /integration 文件夹中创建了一个 test.feature 文件。
似乎 IntelliJ 将该文件重新转换为 Cucumber 功能文件,因为我可以选择在内部运行该功能和测试。
但是,当该功能尝试运行时,这只会给我以下错误:
Error: Could not find or load main class cucumber.cli.Main
Caused by: java.lang.ClassNotFoundException: cucumber.cli.Main
认为这是由于运行配置中缺少 cucumber.cli.Main,我打开它发现它不是。它也不起作用:
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/ib9ZT.png
(在“主类”中,该行的“黄瓜”部分被标记为红色。)
将其更改为“ io.cucumber.core.cli.main”(我相信它是更新的?)没有帮助。
我尝试的最后一步是在插件浏览器中安装 Cucumber Js 插件。似乎没有任何区别。
我不敢尝试更多,因为根据我的经验,过多地使用 maven 可能会破坏任何项目,以至于我不得不从头开始。