timjroberts / cucumber-js-tsflow

Provides 'specflow' like bindings for Cucumber.js in TypeScript 1.7+.
MIT License
133 stars 34 forks source link

how to handle doc strings? #95

Closed garfieldnate closed 1 year ago

garfieldnate commented 2 years ago

What's the correct syntax for retrieving a doc string parameter in the bound function? In plain Cucumber JS, the syntax I'm trying to use is shown here: https://github.com/cucumber/cucumber-js/blob/main/features/doc_string.feature.

Fryuni commented 1 year ago

Doc strings can be used without modifications with this library. It will be passed as a string after the last argument from the pattern.

Example:

Feature: Foo
    Scenario: Bar
        When I use a "parameter" with a doc string:
            """
            Some text
            """
@binding()
class Steps {
    @when('I use a {string} with a doc string:')
    public paramWithDocString(param: string, docString?: string): void {
       // Notice that the pattern guarantees that a string parameter will be given,
       // but the doc string might be missing. It is up to the step function to handle that case.
       // Usually, ending the step with a : is a good enough indicator that a doc string
       // is expected.
    }
}