Deterministic seed, common path
- Input
- createCnhFromBase('123456789')
- Expected output
- 123 456 789-00
Simple sequential base, easy to remember in a test; both check digits land on 00 without triggering the conditional adjustment.
Synthetic Brazilian driver license number for test fixtures
A CNH fixture needs 11 coherent digits: a 9-digit base and 2 modulo-11 check digits, one dependent on the other. Calling the random generator on every test works, but breaks CI reproducibility; this page shows how to pin the seed, read the deterministic value and handle the filter that discards repeated sequences before they reach your test.
Simple sequential base, easy to remember in a test; both check digits land on 00 without triggering the conditional adjustment.
This base is the rare case where the first calculation exceeds 9 and the second calculation goes negative before adjustment, exercising both special rules at once.
The calculation mathematically closes on 11111111111, but the repeated-digit filter discards that value before it ever reaches your fixture.
No. It only follows the mathematical format used by form validators.
Inject your own digit function in place of the default random source, always returning the same sequence, or call the function that takes the 9-digit base directly; any test comparing against a fixed value should use one of these two paths, never the generator with raw randomness.
Probably because the test recalculates both digits independently, without replicating the conditional adjustment that resets the first digit and subtracts 2 from the second when the first calculation's raw result exceeds 9; that adjustment only shows up for a fraction of possible bases, so the bug hides in most test cases.
No: even when the check-digit calculation mathematically closes on a sequence like 11111111111, a separate filter rejects any result where all 11 digits are identical, retrying up to 20 times before falling back to the fixed value.
No, the number only reproduces the 11-digit format and the two-check-digit modulo-11 calculation; it does not query any driving record, license category, point balance or suspension status.
Generation happens locally in the browser. Analytics receives only action, status, type and format, never the generated CNH.