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

Upcoming features

Open amiceli opened this issue 1 year ago • 10 comments
trafficstars

A list of feature with I'm working on it :

  • [X] check missing Scenario / step / rule before afterAll of describe sine v3.4.0
  • [X] throw error before running tests, like missing Scenario sine v3.4.0
  • [ ] move logic to manage Scenario inside ScenarioParent
  • [ ] move step logic to StepAble
  • [x] remove loadFeatures : multiple Feature isn't recommended in Gherkin rules #86 / v3.3.2
  • [X] add Gherkin alias like Example for Scenario #86 / v3.3.2
  • [ ] Support Data Table : #134
  • [X] Support DocStrings : since v3.6.0 #112

amiceli avatar May 14 '24 20:05 amiceli

Maybe convert this to a list of tasks rather than bullets to show the progress?

Ex:

  • [ ] check missing Scenario / step / rule before afterAll of describe ...

Thanks for continuing this work! I am onboarding a new member onto our team that will be responsible for much of the TDD/BDD. So hoping to strengthen this lib as we get more familiar with testing patterns.

charlieforward9 avatar May 15 '24 22:05 charlieforward9

Yes a good idea, I will do it ;)

amiceli avatar May 16 '24 07:05 amiceli

It would be ideal to support DataTables and Doc Strings

chiqui3d avatar Jul 29 '24 10:07 chiqui3d

Yes it's planned, I don't know when and how, but I want implement this features ;). I'm updated this issue.

amiceli avatar Jul 29 '24 12:07 amiceli

Hi there,

I have a couple of questions :

  • I noticed that Data Table isn't currently supported. Is there a specific reason why @gherkin/cucumber wasn't used for parsing/compiling feature files? I actually tried implementing the Data Table parsing myself, which is why I’m curious about your choice. https://github.com/cucumber/gherkin/tree/main/javascript
  • Also, do you think it would be possible to make a step reusable across multiple scenarios? And in any case, would that be a good practice in your opinion?

Thank you for your insights!

BriacHarfang avatar Sep 27 '24 14:09 BriacHarfang

@BriacHarfang Hi, Currently I prefer use my own parser, we talked about it here ;). I will add Data Table on vitest-cucumber.

Make a step reusable it's a good topic. I will research and test how to add it on vitest-cucumber. Something like that: reusable steps example with jest-cucumber ?

amiceli avatar Sep 27 '24 19:09 amiceli

@BriacHarfang I made a test for reusable step with current vitest-cucumber version :

describe('re-use steps', () => {
    const content = `
        Feature: re-use step
            Scenario: first scenario
                Given I use reusable step
                Then  It's call on this scenario
            Scenario: second scenario
                Given I use reusable step
                Then  It's call a second time on this scenario
    `
    const feature = FeatureContentReader.fromString(
        content.split('\n'),
    ).parseContent()

    describeFeature(feature, (f) => {
        let called = 0

        const reuseGiven = (Given: StepCallbackDefinition) => {
            Given('I use reusable step', () => {
                called += 1
            })
        }

        f.Scenario('first scenario', (s) => {
            reuseGiven(s.Given)
            s.Then("It's call on this scenario", () => {
                expect(called).toBe(1)
            })
        })

        f.Scenario('second scenario', (s) => {
            reuseGiven(s.Given)
            s.Then("It's call a second time on this scenario", () => {
                expect(called).toBe(2)
            })
        })
    })
})

What do you thing ? Or you imagined different use case ?

amiceli avatar Sep 27 '24 19:09 amiceli

Thanks you for your answers :)

About the reusable steps, I was thinking of something like this:

Scope Step definitions aren’t linked to a particular feature file or scenario. The file, class or package name of a step definition does not affect what Gherkin steps it will match. The only thing that matters is the step definition’s expression.

Source : https://cucumber.io/docs/cucumber/step-definitions/?lang=javascript#scope

In my opinion, for unit tests, the solution you suggested would work just fine. But for components/integration tests, it gets trickier. For instance, with a step like Given a user with "admin" role, I’d like to be able to share this step across different scenarios and features.

Having tried it, I know that what I'm suggesting is not easy to implement, especially when it comes to sharing the Vitest context across different steps.

BriacHarfang avatar Sep 30 '24 08:09 BriacHarfang

Currently I'm checking web for scope ;). I don't totally understand what is it, but I like this idea.

amiceli avatar Oct 01 '24 19:10 amiceli

I found world feat in cucumber-js doc. Does scope is something like that ? I found it useful ;).

amiceli avatar Oct 01 '24 19:10 amiceli

I close this issue, I will use milestone for next feature ;).

@BriacHarfang I made vitest-cucumber very related to feature file, we discussed it about it in #142. So step like Given won't be called without Scenario.

But I'm thinking about "shared steps" or "inherited scenario". We can create a discussion for it ;).

amiceli avatar Oct 26 '24 16:10 amiceli