spec with randNumber failed randomly
kobenguyent opened this issue · comments
KobeN commented
Is this a regression?
No
Description
There are some intermittently failed specs using randNumber
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Summary of all failing tests
FAIL src/tests/json.spec.ts (7.215 s)
● randJSON › when it returns the expected values › should return an object with a random number of keys
Max must be bigger than min
51 | }: RandomInRangeOptions = {}) {
52 | if (max < min) {
> 53 | throw new Error('Max must be bigger than min');
| ^
54 | }
55 | return Number((random() * (max - min) + min).toFixed(fraction));
56 | }
at getRandomInRange (src/lib/core/core.ts:53:11)
at src/lib/number.ts:62:33
at fake (src/lib/core/core.ts:29:12)
at randNumber (src/lib/number.ts:57:14)
at Object.<anonymous> (src/tests/json.spec.ts:20:33)
Test Suites: 1 failed, 93 passed, 94 total
Tests: 1 failed, 418 passed, 419 total
Snapshots: 0 total
Time: 29.41 s
Ran all test suites.
FAIL falso packages/falso/src/tests/number.spec.ts
● randNumber › should return a random number with fraction
expect(received).toBe(expected) // Object.is equality
Expected: false
Received: true
12 | it('should return a random number with fraction', () => {
13 | const num = randNumber({ min: 0.1, max: 1, fraction: 2 });
> 14 | expect(Number.isInteger(num)).toBe(false);
| ^
15 | });
Please provide the environment you discovered this bug in
No response
Anything else?
No response
Do you want to create a pull request?
No
Fritiof Rusck commented
Hmm? that's weird because that test succeeded when I merged a branch a couple of days ago. Is this flakey or does it happen every time?
KobeN commented
It's flaky @PumpedSardines very intermittently failed.