Reputation: 1795
I have a test that looks like the following:
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
Here's the steps implementation:
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)
})
When running cypress, I get the following error:
Error: Step implementation missing for: I should see "Test Bar Foo" in the content section
According to Cucumber parameter types documentation, {string}
syntax should detect the "Test Bar Foo"
string.
If I change {string}
to {word}
, the step definition is picked up and the test run just fine.
What am I missing?
Upvotes: 0
Views: 1206
Reputation: 12039
From Cucumber Expressions - Cucumber Documentation:
{string}
Matches single-quoted or double-quoted strings, for example"banana split"
or'banana split'
(but notbanana split
). Only the text between the quotes will be extracted. The quotes themselves are discarded. Empty pairs of quotes are valid and will be matched and passed to step code as empty strings.
So you don't need the extra "
in your step definition:
Then('I should see {string} in the content section', (content) => {
cy.findByTestId(exampleSelectors.testContent).should('contain', content)
})
Upvotes: 2