Closed artinalbert closed 9 months ago
Thanks for the high-quality MRE repo @artinalbert, much appreciated!
The problem with running Cucumber several times in the same Node.js process is that after the first time all the step/support code files are loaded, they are cached by the module loader, so if they are requested a second time (by the next run) there'll be no error but the code is not executed again and so the steps are not registered.
To deal with this we have a function called loadSupport
where you load the support code once upfront and can then reuse it on multiple calls to runCucumber
in the same process.
I raised a PR against your repo which now passes https://github.com/artinalbert/cucumber-in-loop-minimum-viable-example/pull/1 - hope it makes sense, let me know if you have any questions.
Thank you for the quick response and the PR that made it clear!
👓 What did you see?
step definitions are undefined in subsequent runs of Cucumber when Cucumber is run in a loop
✅ What did you expect to see?
steps should be defined in the subsequent runs of Cucumber
📦 Which tool/library version are you using?
"@cucumber/cucumber": "^10.0.0",
🔬 How could we reproduce it?
I have made a minimum viable example. To run the example run : npx ts-node src/index.ts
minimum reproducible example: https://github.com/artinalbert/cucumber-in-loop-minimum-viable-example/
This text was originally generated from a template, then edited by hand. You can modify the template here.