seed

Seed utilities for testing and randomness control. These set values and can be overridden in tests to provide predictable results.

Description:
  • Seed utilities for testing and randomness control. These set values and can be overridden in tests to provide predictable results.

Source:

Methods

(inner) random() → {Number}

Description:
  • Returns a random value (Math.random() by default).

Source:
Example
seed.random()
=> 0.42480169934972056
Returns:

a random number between 0 and 1.0. This can be overridden in tests to control for randomness.

Type
Number

(inner) restore()

Description:
  • Restores the seed functions to their default implementations.

Source:
Example
seed.restore()

(inner) timestamp() → {Number}

Description:
  • Returns a long value (new Date().getTime() by default).

Source:
Example
seed.timestamp()
=> 1571246424383
Returns:

milliseconds since the epoch. This can be overridden in tests to control for time.

Type
Number