vitest-cucumber
vitest-cucumber copied to clipboard
Upcoming features
A list of feature with I'm working on it :
- [X] check missing Scenario / step / rule before
afterAllofdescribesine 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: multipleFeatureisn't recommended in Gherkin rules #86 / v3.3.2 - [X] add Gherkin alias like
ExampleforScenario#86 / v3.3.2 - [ ] Support Data Table : #134
- [X] Support DocStrings : since
v3.6.0#112
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.
Yes a good idea, I will do it ;)
It would be ideal to support DataTables and Doc Strings
Yes it's planned, I don't know when and how, but I want implement this features ;). I'm updated this issue.
Hi there,
I have a couple of questions :
- I noticed that
Data Tableisn't currently supported. Is there a specific reason why@gherkin/cucumberwasn't used for parsing/compiling feature files? I actually tried implementing theData Tableparsing 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 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 ?
@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 ?
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.
Currently I'm checking web for scope ;). I don't totally understand what is it, but I like this idea.
I found world feat in cucumber-js doc. Does scope is something like that ? I found it useful ;).
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 ;).