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

Unit test for logarithmic scale fails in Firefox #5829

Closed
jtagscherer opened this issue Nov 12, 2018 · 3 comments · Fixed by #5833
Closed

Unit test for logarithmic scale fails in Firefox #5829

jtagscherer opened this issue Nov 12, 2018 · 3 comments · Fixed by #5833

Comments

@jtagscherer
Copy link
Contributor

Two assertions of the unchanged test suite for logarithmic scales consistently fail on my machine due to floating point inaccuracy. This only happens in Firefox, and not in Chrome. Obviously, it also does not seem happen on the CI server.

Firefox 63.0.0 (Mac OS X 10.14.0) Logarithmic Scale tests when dataset min point {x: 6.3, y: 6.3}, max point {x:78, y:78}, ticks.min: 0 and axis is "x"; expect: min = 0, max = 80, first tick = 6; should get the correct pixel value for a point FAILED
	Expected 505.14327434188084 to be 505.1432743418808.
	@test/specs/scale.logarithmic.tests.js:1097:54
	Expected 42.93333244323725 to be 42.933332443237305.
	@test/specs/scale.logarithmic.tests.js:1112:54

Possible Solution

Instead of using the toBe matcher in these lines, we could use the toBeCloseTo matcher. Since the value we are checking is a pixel obtained through the scale$getPixelForValue method, the toBeCloseToPixel matcher could also be a good choice.

Furthermore, there are multiple other lines with similar pixel comparisons that are sensitive to floating point inaccuracies. Changing these as well would make the test suite more robust.

@simonbrunel
Copy link
Member

We should use toBeCloseToPixel instead of toBeCloseTo every time we check pixel values so feel free to update unit tests using this matcher. At some point, I would love to see most of these pixel tests to be converted into image based tests.

@jtagscherer
Copy link
Contributor Author

@simonbrunel Image-based tests sound like a great idea for the future! For now, I have updated the matchers in question in PR #5833.

@simonbrunel simonbrunel added this to the Version 2.8 milestone Nov 14, 2018
@simonbrunel
Copy link
Member

@jtagscherer yes of course, I wasn't expecting you to convert existing tests for this round :)

Thanks for your help.

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