1 | # Debugging
|
2 |
|
3 | When a value generated by `any` causes a test to fail inconsistently, it can
|
4 | be incredibly difficult to track down the failing conditions. In order to
|
5 | reliably reproduce the problem, you need to be able to get `any` to repeatedly
|
6 | produce the same value.
|
7 |
|
8 | ## Determine the seed
|
9 |
|
10 | The [debug](https://www.npmjs.com/package/debug) library is in place to enable
|
11 | revealing the `seed` that was used for the randomness of generated values. This
|
12 | means that the `seed` is not displayed by default, but can be revealed by
|
13 | instructing `debug` to output logs for `any`:
|
14 |
|
15 | ```sh
|
16 | $ DEBUG=any mocha --recursive test/unit/
|
17 |
|
18 | Thu, 29 Jun 2017 02:13:29 GMT any randomness seed: 0.4070123094134033
|
19 | ```
|
20 |
|
21 | ## Set the seed
|
22 |
|
23 | Once a problematic `seed` is determined, it can be provided back to any so that
|
24 | the generation becomes repeatable.
|
25 |
|
26 | ```sh
|
27 | $ ANY_SEED=0.4070123094134033 mocha --recursive test/unit/
|
28 | ```
|