You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you execute this block enough times you will experience an intermittent failure.
describe('maybe',()=>{it('should always return the callback result when probability is 1',()=>{constactual=faker.helpers.maybe(()=>'foo',{probability: 1});expect(actual).toBe('foo');});});
On dry reading the code this can happen when faker.datatype.float({ min: 0, max: 1}) returns 1. The subsequent 1 < 1 check fails and the callback is never executed.
Minimal reproduction code
describe('maybe',()=>{it('should always return the callback result when probability is 1',()=>{jest.spyOn(faker.datatype,'float').mockReturnValueOnce(1);constactual=faker.helpers.maybe(()=>'foo',{probability: 1});expect(actual).toBe('foo');});});
Additional Context
A quick 1 <= 1 fix won't work as maybe should fail { probability: 0 } and faker.datatype.float returning 0.
Pre-Checks
Describe the bug
If you execute this block enough times you will experience an intermittent failure.
On dry reading the code this can happen when faker.datatype.float({ min: 0, max: 1}) returns 1. The subsequent 1 < 1 check fails and the callback is never executed.
Minimal reproduction code
Additional Context
A quick
1 <= 1
fix won't work asmaybe
should fail{ probability: 0 }
andfaker.datatype.float
returning 0.Environment Info
Which module system do you use?
Used Package Manager
npm
The text was updated successfully, but these errors were encountered: