amiceli / vitest-cucumber

Use gherkin in your unit tests with vitest
https://vitest-cucumber.miceli.click
36 stars 3 forks source link

fix(scenario-outlines): capture scenarioStepsToRun in closure #32

Closed chrisjarman closed 7 months ago

chrisjarman commented 8 months ago

The "multiple examples" aspect of the scenario outline feature is broken. The synchronous loop over each of the examples causes the test runner to execute the test suite N times, but it does so on each iteration with the last item of example data, rather than the _i_th item.

This change simply creates a closure around the current iteration's step functions, so that they aren't clobbered on the next go-around of the loop.

amiceli commented 7 months ago

@chrisjarman really thank you ! 🍾 I will merge it, I'm working to approve my unit tests about ti.

amiceli commented 7 months ago

I reproduced bug, I merge your PR and add unit test for it. Really thank you @chrisjarman .

chrisjarman commented 7 months ago

@amiceli You're very welcome! Thank you for writing this library - I'm finding it really useful. Glad to be able to contribute in some small way.

BTW, thank you for digging in and reproducing this; I'm painfully aware I didn't add any reproduction steps or test cases around this. It was a Friday afternoon; I needed to make my scenarios work for a demo video, and after successfully patching my local install of your package I thought I'd better share it!