bencompton / jest-cucumber

Execute Gherkin scenarios in Jest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to generate scenarios with `it` alias instead of `test`

cscheffauer opened this issue · comments

Hi,

right now when code is generated, the tests always start with Jests test keyword. Would it be possible to add an option to use the it alias instead? see here

I think the pieces of code which should be touched then are here:

return `test('${scenarioTitle.replace(/'+/g, `\\'`)}', ({ ${stepKeywords.join(', ')} }) => {\n${indent(steps, 1).slice(0, -1)}\n});`;

Actually, this is already possible by naming the test function argument whatever you like. For example, both of these are equivalent:

defineFeature(feature, (test) => {
    test('Entering a correct password', ({ given, when, then }) => {
...
...
defineFeature(feature, (scenario) => {
    scenario('Entering a correct password', ({ given, when, then }) => {
...
...

The main downside is that certain tools may not work, like the Jest VSCode plug-in might not recognize a scenario in the same it recognizes a test.