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

Test failure for latitude #2080

Closed
matthewmayer opened this issue Apr 22, 2023 · 5 comments · Fixed by #2116
Closed

Test failure for latitude #2080

matthewmayer opened this issue Apr 22, 2023 · 5 comments · Fixed by #2116
Assignees
Labels
c: test m: location Something is referring to the location module
Milestone

Comments

@matthewmayer
Copy link
Contributor

FAIL test/location.spec.ts > location > random seeded tests for seed 4743915782701865 > latitude() > returns latitude with min and max and default precision

@matthewmayer matthewmayer added s: pending triage Pending Triage c: test m: location Something is referring to the location module labels Apr 22, 2023
@ST-DDT
Copy link
Member

ST-DDT commented Apr 22, 2023

Please also link to the failing pipeline for more information.
https://github.com/faker-js/faker/actions/runs/4771531155/jobs/8483518852

@matthewmayer
Copy link
Contributor Author

matthewmayer commented Apr 22, 2023

expect(
            latitude.toString().split('.')[1].length,
            'The precision of latitude should be 4 digits'
          ).lessThanOrEqual(4);

The problem is that this uses faker.number.float which occasionally (about every 10,000 test runs) will return say 2.0000 which is just returned as 2

for (let i = 0;i<100000;i++) {
    const l = faker.location.latitude({ max: 5, min: -5 }); 
    if (l.toString().split(".")[1]==undefined) {
        console.log(l)
    }
}
-1
-3
-5
-4
5
-2
0
0
5
-2
2
-5
1
-4
-4
5
2

@ST-DDT
Copy link
Member

ST-DDT commented Apr 22, 2023

We could remove the default precision from the call, since it is a number anyway?

@matthewmayer
Copy link
Contributor Author

I would fix the test not the method. Expect no decimal point or no more than 4 digits after the decimal point.

@Shinigami92
Copy link
Member

I'm also for fixing the test, not the method implementation

If we want to change the implementation, we should do this later and with a needs decision

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: test m: location Something is referring to the location module
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants