Generate a single value #4942
Answered
by
dubzzz
denizdogan
asked this question in
Q&A
-
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.
Answered by
dubzzz
Apr 23, 2024
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.
0 replies
Answer selected by
dubzzz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to 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
.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