【问题标题】:Step definition folder structure in cypress cucumber preprocessor柏树黄瓜预处理器中的步骤定义文件夹结构
【发布时间】:2021-09-24 06:58:38
【问题描述】:

版本

  • 赛普拉斯版本:8.4.0
  • 预处理器版本:4.2.0
  • 节点版本:12.18.2

大家好,如果这是一个愚蠢的问题,我深表歉意,我是柏树的新手/菜鸟,更不用说柏树 + 黄瓜了。

所以我用 cucumber 编写了一些自动化测试,它们运行良好。我在集成文件夹中有功能文件,在集成文件夹中也有步骤定义文件夹。现在我正在尝试构建一些结构,其中在集成下我有一个名为 step_definitions 的文件夹(将在屏幕截图中显示得更好)。

folder structure

在 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.

任何指针表示赞赏:)

【问题讨论】:

    标签: cypress cypress-cucumber-preprocessor


    【解决方案1】:

    在我看来,您在"stepDefinitions": "step_definitions" 中遇到的问题您是否尝试过提供像"stepDefinitions": "cypress/integration/step_definitions" 这样的完整路径?

    【讨论】:

    • 我同意。我的也是这样设置的。
    • 我遇到了和记者一样的错误。即使给出整个路径,问题仍然存在。请问还有什么解决办法吗?
    【解决方案2】:

    您应该将 nonGlobalStepDefinitions 设置为 false 或删除此设置,因为您没有用于 step_definitions 的单独文件夹,但它位于集成文件夹中。

    因此,为了使用您的结构,请将 package.json 文件中的该部分修改为:

    “柏树黄瓜预处理器”:{ "commonPath": "cypress/integration/step_definitions/common", “stepDefinitions”:“柏树/集成/step_definitions” }

    这就够了。它有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-12
      • 1970-01-01
      • 2022-06-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多