new feat: pick default seed from ENV variable
Author: gerardolimaCreated Nov 18, 2025Updated Nov 18, 2025
I'm working in a repo that contains usage of const chance = new Chance() (without a seed), which makes the tests irreproduceable, when they fail. As developes are not very disciplined, I thought about creeating a way to make tests reproduceable, even without explicitly passing the seed to the consrtuctor.
Would you be open to consider a PR to set a default seed from an ENV variable, when they exist (ie: RANDOM_SEED)?
new Chance(mySeed): use Myseed, no change;new Chance()when ENV variableRANDOM_SEEDdoes NOT exists: use random seed, no change;new Chance()when ENV variableRANDOM_SEEDexists: use process.env['RANDOM_SEED'] as seed
Source: chancejs/chancejs