fledge
fledge copied to clipboard
Use JSON for snapshotting data
or perhaps glimpse()
, instead of tibbles which abbreviate long strings.
Now in #358
Actually not really.
I wonder whether the easiest solution would be to change the way the fledge tibble is printed when in testthat. Which does not sound really "simple".
A simple solution to have no truncation would be to use expext_snapshot()
with withr::local_options(width = "10000")
.
Otherwise, really changing the print method inside testthat for such tibbles?
I don't mind . %>% to_snapshot_json()
with a suitable implementation. It's explicit.
We can discuss better solutions in testthat.
FWIW, we have similar problems in dm, there it's toJSON(pretty = TRUE)
for now.
Standardizing a custom helper that looks the same across packages seems like a good way in the short term.
I think what I'd like is an argument like transform
but that'd be transform_output
and be applied directly to the output.
E.g.
expect_snapshot(code, transform_output = function(x) toJSON(x, pretty = TRUE))
Maybe we need a new snapshot()
method with an easy way to override implementations inside tests. But this seems like a discussion for {testthat}.
https://github.com/r-lib/testthat/issues/1651
To clarify, should there be work on this inside fledge before there's any response to the testthat issue mentioned in my previous comment?
I'd like to avoid blockers as much as possible. You filed an issue, we can work around by pointing in the code to that issue. If and when a solution is available, we can apply that solution here.
For minor problems in upstream repos, we can also provide a PR. Output transformation looks like a major issue that might require a lot of focus from the maintainers, so better to avoid a blocker.
Also, we might need to reprioritize.
fledge has now expect_snapshot_tibble()
but we forgot to close this.