Skip to content

setOffset for tests#2376

Merged
mbostock merged 5 commits intomainfrom
mbostock/simpler-offset
Mar 11, 2026
Merged

setOffset for tests#2376
mbostock merged 5 commits intomainfrom
mbostock/simpler-offset

Conversation

@mbostock
Copy link
Member

@mbostock mbostock commented Mar 7, 2026

Instead of having a typeof it === "undefined" check, use the new setOffset so that we it’s more explicit what offset is used for testing. This should make it easier to adopt Vitest and/or change the offset used for testing in the future.

This also fixes explicitly passes Plot’s offset to axis.offset where we use d3-axis. But this currently has no effect on tests since d3-axis defaults to an offset of 0.5 in a headless environment, which is the same offset we use for Plot tests, even though Plot now defaults to an offset of 0 in a headless environment.

@mbostock mbostock requested a review from Fil March 7, 2026 16:51
@mbostock mbostock enabled auto-merge (squash) March 7, 2026 17:03
Copy link
Contributor

@Fil Fil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added an offsets test that sets the offset to 0, then back to 0.5 and overlays the two images.

Image

@mbostock mbostock merged commit 33a3ea1 into main Mar 11, 2026
1 check passed
@mbostock mbostock deleted the mbostock/simpler-offset branch March 11, 2026 12:13
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

Successfully merging this pull request may close these issues.

2 participants