cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.01k stars 1.09k forks source link

Prevent mutations on world parameters leaking between test cases #2362

Closed davidjgoss closed 6 months ago

davidjgoss commented 6 months ago

🤔 What's changed?

Clone the world parameters before creating each world instance. This prevents user code that updates the world parameters from leaking those changes across different test cases.

Also, type the worldParameters as JsonObject in configuration to enforce it should be JSON serialisable.

It would have been nice to somehow ensure immutability even between hooks/steps in the same test case. But realistically, users can have custom world instances, they can do what they want with the parameters object they are passed, so there's only so much we can do as the orchestrator.

⚡️ What's your motivation?

Fixes #2356

🏷️ What kind of change is this?

📋 Checklist:


This text was originally generated from a template, then edited by hand. You can modify the template here.

coveralls commented 6 months ago

Coverage Status

coverage: 98.383%. remained the same when pulling e0936026a65734547ca72bd844880814f4011e1e on fix/world-parameters-immutable into 052ac1abf33824b954f2524d610e370e81a02db1 on main.