[Do not merge] Add fallback tests for plots#75
Open
vandenman wants to merge 2 commits intojasp-stats:masterfrom
Open
[Do not merge] Add fallback tests for plots#75vandenman wants to merge 2 commits intojasp-stats:masterfrom
vandenman wants to merge 2 commits intojasp-stats:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a more robust plot-testing strategy to jaspTools by introducing a ggplot2 structural snapshot fallback when the existing vdiffr SVG comparison fails, reducing OS-specific fragility in plot tests.
Changes:
- Extend
expect_equal_plots()to run vdiffr first and (for ggplot objects) fall back to a structural snapshot comparison. - Add unit tests and reference
.rdssnapshots for the fallback mechanism. - Minor documentation/example formatting updates in Rd files and roxygen examples.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/testthat/test-expect-equal-plots-fallback.R | Adds test coverage for vdiffr-failure fallback behavior, update mode, and snapshot comparison. |
| tests/testthat/_snaps/expect-equal-plots-fallback/reference_plotobject/new-plot.rds | Adds a structural reference snapshot used by the fallback mechanism. |
| tests/testthat/_snaps/expect-equal-plots-fallback/reference_plotobject/demo-plot.rds | Adds a structural reference snapshot used by the fallback mechanism. |
| R/testthat-helper-plots.R | Implements fallback orchestration, ggplot structural snapshot generation/compare, and snapshot path helpers. |
| NAMESPACE | Registers S3 methods for expect_doppelganger_fallback. |
| DESCRIPTION | Adds ggplot2 to Suggests for the structural fallback implementation/tests. |
| man/testAnalysis.Rd | Minor reflow/cleanup of includeAll documentation. |
| man/expect_equal_tables.Rd | Example formatting change (line breaks/indent). |
| man/analysisOptions.Rd | Example formatting change (comment moved to its own line). |
| R/testthat-helper-tables.R | Roxygen example formatting change to match Rd formatting. |
| R/options.R | Roxygen example formatting + whitespace cleanup. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes https://github.com/jasp-stats/INTERNAL-jasp/issues/3161
[Do not merge] until we've tried this out in practice for a few modules.
Problem
The current plot tests are too fragile. They often fail due to minor differences between OSes that can be really hard to fix and are also notoriously time-consuming to debug.
Solution in this PR
1a. test passes? pass ✔️
1b. test fails? go to 2.
2a. yes? go to 3.
2b. no? fail ❌
3a. test passes? pass ✔️
3b. test fails? fail ❌
Some design details:
expect_doppelganger_fallback.