【发布时间】:2022-01-21 22:50:44
【问题描述】:
我将 cypress 与 cucumber-js 一起使用,我需要定义自己的数据类型。我做了与https://github.com/TheBrainFamily/cypress-cucumber-preprocessor#custom-parameter-type-resolves 中描述的完全相同的事情。
这意味着: 赛普拉斯 > 支持 > step_definitions > customParameterTypes.js 我写道:
const blogType = ["sport", "gaming"]
defineParameterType({
name: "blogType",
regexp: new RegExp(blogType.join("|"))
})
在我的 BDD .feature 文件中,我有:
Given I have empty blog
And Blog has default structure for sport
在我的柏树文件中:
Given(' Blog has default structure for {blogType}', blogType => {...})
当我开始测试时,我得到:
The following error originated from your test code, not from Cypress.
> Undefined parameter type {blogType}
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
Cypress could not associate this error to any specific test.
【问题讨论】:
-
在您的
defineParameterType()中,您在steps上使用.join(),但我没有在您共享的代码中看到steps声明。 -
@PeaceAndQuiet 啊...抱歉...只是从代码中复制错误...编辑...但它仍然是同样的问题。
标签: cucumber cypress bdd cypress-cucumber-preprocessor user-defined-data-types