Skip to content

Unit test for logarithmic scale fails in Firefox #5829

Closed
@jtagscherer

Description

@jtagscherer

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions