Replies: 2 comments 3 replies
-
I think this is an issue for https://github.com/concordancejs/concordance/ which generates the diffs. Would you mind opening it there? Some questions we'd need to resolve:
Perhaps some of those things could be configurable on a a per-assertion basis but we'd need to support it in Concordance first. (I'm closing this issue for housekeeping purposes, but let's keep the conversation going.) |
Beta Was this translation helpful? Give feedback.
-
Here's an example of how jest outputs diffs: - Snapshot - 2
+ Received + 34
@@ -1,7 +1,38 @@
- "module Tailwind.WithAutoprefixer exposing (..)
+ Object {
+ "breakpointsModule": "module Tailwind.WithAutoprefixer.Breakpoints exposing (..)
+
+ import Css
+ import Css.Media
+
+
+ sm : List Css.Style -> Css.Style
+ sm =
+ Css.Media.withMediaQuery [ \"(min-width: 640px)\" ]
+
+
+ md : List Css.Style -> Css.Style
+ md =
+ Css.Media.withMediaQuery [ \"(min-width: 768px)\" ]
+
+
+ lg : List Css.Style -> Css.Style
+ lg =
+ Css.Media.withMediaQuery [ \"(min-width: 1024px)\" ]
+
+
+ xl : List Css.Style -> Css.Style
+ xl =
+ Css.Media.withMediaQuery [ \"(min-width: 1280px)\" ]
+
+ xxl : List Css.Style -> Css.Style
+ xxl =
+ Css.Media.withMediaQuery [ \"(min-width: 1536px)\" ]
+ ",
+ "utilitiesModule": "module Tailwind.WithAutoprefixer.Utilities exposing (..)
+
import Css
import Css.Global
import Css.Media
@@ -32865,6 +32896,7 @@
animate_bounce : Css.Style
animate_bounce =
Css.property \"animation\" \"bounce 1s infinite\"
- "
+ ",
+ } As you can see, it uses a standard syntax for eliding unchanged lines from a diff: This format seems to be called unified diff format.
No. While it's true that the biggest use-case for this is when two huge files are mostly similar, except for one or two small differences, I still want the output to contain all information for the difference. If there's so much diff that the output becomes long, so be it. I feel it would be confusing/something unpredicted if it wouldn't output the whole diff, even with a message.
It looks like by default, jest prints 5 lines above and below each diff block, which is a default setting I never thought of changing :) I took a look at the GNU diff tool (
Should we keep the conversation going here and create an issue in concordance once we've found a good solution, or should I create an issue right away? |
Beta Was this translation helpful? Give feedback.
-
What you're trying to do
I'm writing snapshot tests for a code generator. These snapshots are just strings.
Why you can't use AVA for this
The snapshots are ~50k lines of code. If there's some line diff in there, AVA prints the whole snapshot. This fills my terminal buffer so much, I can't even scroll to the actual diff anymore.
And maybe how you think AVA could handle this
I've switched to AVA from Jest (yay!). If the file was big, jest would only print parts of the file with some lines of context lines above and below differences, similar to the unix diff command.
I don't think everyone prefers this, so ideally it'd become a setting in the
.snapshot
function.Beta Was this translation helpful? Give feedback.
All reactions