fledge icon indicating copy to clipboard operation
fledge copied to clipboard

Use JSON for snapshotting data

Open krlmlr opened this issue 2 years ago • 10 comments

or perhaps glimpse(), instead of tibbles which abbreviate long strings.

krlmlr avatar Jun 05 '22 03:06 krlmlr

Now in #358

maelle avatar Jun 27 '22 09:06 maelle

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".

maelle avatar Jun 27 '22 09:06 maelle

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?

maelle avatar Jun 27 '22 09:06 maelle

I don't mind . %>% to_snapshot_json() with a suitable implementation. It's explicit.

We can discuss better solutions in testthat.

krlmlr avatar Jun 27 '22 09:06 krlmlr

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.

krlmlr avatar Jun 27 '22 09:06 krlmlr

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))

maelle avatar Jun 27 '22 09:06 maelle

Maybe we need a new snapshot() method with an easy way to override implementations inside tests. But this seems like a discussion for {testthat}.

krlmlr avatar Jun 27 '22 09:06 krlmlr

https://github.com/r-lib/testthat/issues/1651

maelle avatar Jun 27 '22 09:06 maelle

To clarify, should there be work on this inside fledge before there's any response to the testthat issue mentioned in my previous comment?

maelle avatar Aug 25 '22 12:08 maelle

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.

krlmlr avatar Aug 27 '22 04:08 krlmlr

fledge has now expect_snapshot_tibble() but we forgot to close this.

maelle avatar Nov 10 '22 11:11 maelle