vitest-cucumber icon indicating copy to clipboard operation
vitest-cucumber copied to clipboard

Unable to use Cucumber step expression

Open cgaulay opened this issue 5 months ago • 3 comments

Hello,

I would like to use Cucumber step expression like in : https://vitest-cucumber.miceli.click/features/step-expression/ to be able to use parameter in cucumber step but the value of the parameter is always "undefined".

For example, my cucumber step is : When the user fill "test" in the field

And the step definition is : When('the user fill {string} in the field', async(ctx : TestContext, value: string) => { await appiumActions.fillInputByKey( 'search_input', value ); });

Then the value of the parameter "value" is always "undefined". What is the problem ?

I'm using @amiceli/vitest-cucumber": "^5.2.1" with "vitest": "^3.2.4".

Thank you in advance. Best regards.

cgaulay avatar Nov 13 '25 09:11 cgaulay

You have a typo error. In feature you have When the use fill "test" in the field, but in spec you have the useR.

A r in missing in your When.

Event if an example of code who it works :

When(
    "the user fill {string} in the field",
    async (ctx: TestContext, value: string) => {
        expect(value).toEqual("test")
    },
)

amiceli avatar Nov 13 '25 10:11 amiceli

Thank you for you answer @amiceli . Sorry for the typo in my description but in my code there is no typo issue. If it was a problem with the typo, I should have the "StepAbleUnknowStepError".

cgaulay avatar Nov 13 '25 11:11 cgaulay

Weird, I've same versions but value isn't undefined.

Can you share full Scenario from feature and spec files ?

amiceli avatar Nov 13 '25 13:11 amiceli