Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec with randNumber failed randomly #341

Open
kobenguyent opened this issue Dec 22, 2022 · 2 comments
Open

spec with randNumber failed randomly #341

kobenguyent opened this issue Dec 22, 2022 · 2 comments

Comments

@kobenguyent
Copy link
Contributor

kobenguyent commented Dec 22, 2022

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

@PumpedSardines
Copy link
Contributor

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?

@kobenguyent
Copy link
Contributor Author

It's flaky @PumpedSardines very intermittently failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants