我有一个如下所示的测试:
Feature: App example
I want to use the application
@focus
Scenario: Showing some text by clicking a button
Given I visit the application
When I click on a test button
Then I should see "Test Bar Foo" in the content section
以下是步骤实现:
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
import exampleSelectors from '../page/example'
const url = 'http://localhost:3000'
Given('I visit the application', () => {
cy.visit(url)
})
When('I click on a test button', () => {
cy.findByTestId(exampleSelectors.testBtn).click()
})
Then('I should see "{string}" in the content section', (content) => {
cy.findByTestId(exampleSelectors.testContent).should('contain', content)
})
运行 cypress 时,出现以下错误:
Error: Step implementation missing for: I should see "Test Bar Foo" in the content section
根据Cucumber 参数类型文档,{string}
语法应该检测"Test Bar Foo"
字符串。
如果我更改{string}
为{word}
,则拾取步骤定义并且测试运行良好。
我错过了什么?