UNPKG

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