oneOfWeighted
oneOfWeighted<
T
>(…arbitraries
):Dependent
<ReturnType
<[...T
][number
][1
]["value"
]>["value"
]>
It generates an integer between 0 and the number of arbitraries passed in, and then generates a weighted value from the corresponding arbitrary.
Example
random(oneOf([2, object({foo: string()})], [1, object({bar: string()})]))// => {foo: "bar"}
random(oneOf([2, object({foo: string()})], [1, object({bar: string()})]))// => {foo: "bar"}
random(oneOf([2, object({foo: string()})], [1, object({bar: string()})]))// => {bar: "foo"}
Type Parameters
• T extends readonly [number
, Arbitrary
<unknown
>][]
Parameters
arbitraries
…[...T[]
]
The arbitraries to select one of.
Returns
Dependent
<ReturnType
<[...T
][number
][1
]["value"
]>["value"
]>
An arbitrary that is randomly chosen from the weighted list.