版本
- Cypress版本:8.4.0
- 预处理器版本:4.2.0
- 节点版本:12.18.2
大家好,如果这是一个愚蠢的问题,我很抱歉,我对柏树很陌生,更不用说柏树+黄瓜了。
所以我用黄瓜写了一些自动化测试,它们运行得很好。集成文件夹中有功能文件,集成文件夹中也有步骤定义文件夹。现在,我正在尝试一些结构,在集成下,我有一个名为step_definitions的文件夹(将在屏幕截图中显示得更好)。
文件夹结构
在package.json中,我放入了以下内容:
"cypress-cucumber-preprocessor": { "nonGlobalStepDefinitions": true, "nonGlobalStepBaseDir": "step_definitions", "commonPath": "common", "stepDefinitions": "step_definitions" }
当我尝试运行测试时,我会得到以下错误:
Error: We've tried to resolve your step definitions at step_definitions, but that doesn't seem to exist. As of version 2.0.0 it's required to set step_definitions in your cypress-cucumber-preprocessor configuration. Look for nonGlobalStepDefinitions and add stepDefinitions right next to it. It should match your cypress configuration has set for integrationFolder. We no longer rely on getting information from that file as it was unreliable and problematic across Linux/MacOS/Windows especially since the config file could have been passed as an argument to cypress.
任何指针都值得赞赏:)
在我看来,"stepDefinitions": "step_definitions"
中的问题是,您是否尝试过像"stepDefinitions": "cypress/integration/step_definitions"
那样给出完整路径?
您应该将nonGlobalStepDefinitions设置为false或删除此设置,因为您没有单独的step_definitions文件夹,但它位于集成文件夹中。
因此,为了使用您的结构,请将package.json文件中的该部分修改为:
"柏树黄瓜预处理器":{"commonPath":"cypry/integration/step_definitions/common";,"stepDefinitions":"cypry/integration/step_definitions";}
这就足够了。它有效。