Generate a single value #4942
-
Is there any built-in way to generate a single value from an Arbitrary? I use this utility, but I feel like there should exist something like this already. import * as fc from "fast-check"
const single = <T>(arb: fc.Arbitrary<T>) => fc.sample(arb, 1)[0] |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
At the moment it's the recommended way. There is no built-in function provided to generate 'random' values outside of a property. To generate random values and drop the bias applied by fast-check you may want to add the |
Beta Was this translation helpful? Give feedback.
At the moment it's the recommended way. There is no built-in function provided to generate 'random' values outside of a property.
To generate random values and drop the bias applied by fast-check you may want to add the
.noBias()
on your arbitraries. Bias being more frequent for the very first generated values the[0]
might be highly impacted by it. More at https://fast-check.dev/docs/core-blocks/arbitraries/combiners/any/#nobias