New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow multiline snapshot label/message #2769
Comments
Official multiline support makes a lot of sense. Would you like to work on it? Incidentally I think we may have a similar problem with test titles. |
Hmm. Test titles? Do you mean you put code examples into test titles? And how that supposed to be rendered in markdown? Currently it's just I think I can work on this as long as we agree on the design and it wouldn't grow much in complexity. One design question I've outlined already - it's whether snapshot label/message should be put inside a blockquote or whether there can/should be other way to handle it. |
Sometimes test titles have new lines which break formatting in the snapshot reports. Those should probably be stripped so the title is on a single line, unless Markdown let's you hard-wrap headings. For individual snapshots we should render multi line block quotes. |
Ah ok. Sanitizing titles makes sense. Although I wouldn't quite call it similar with this. Gotcha on multi line block quotes. |
You're right it's different, your suggestion just reminded me of it. Happy to tackle as a separate piece of work 😊 |
I think What I find the most intimidating now is to find the right place where to put tests. I can provide two separate commits/PRs for these. If this falls into the same new tests category then it will be easier to handle in a single PR. |
It's a bit roundabout but it means we have an integration test for this behavior that we perform using a stable AVA version. Happy to help if you get stuck. |
This is sort of an accidental artifact of features being added over time; the first one(s) got subfolders named after the feature, presumably not anticipating there being quite this many tests, and then later ones followed the pattern. It's also awkward that Personally I'd advocate relocating |
House-keeping is certainly not in scope of this issue. |
Ok, after messing around with tests for a while I think I have it working, albeit with cjs/require rather than module/import inside fixtures. Snapshot label is a pretty straightforward fix. It seems to be a good idea to have titles sanitized as early as possible but that is going to be a breaking change (albeit only in cases affected by extra spaces/line breaks). Is it OK? It is also not so trivial for me to identify the right location in code. Line 2 in a8c908e
And I'm not sure whether the line Line 96 in a8c908e
Snapshot report and stdout are pretty obvious things to test. Are there any other places to test the title? Making the change backwards-compatible by comparing sanitized titles everywhere (I haven't looked into how many relevant places there might be) - sounds like snowballing the issue further more. |
I made a PR #2773 with snapshot labels only for now. |
Fixes #2769. Co-authored-by: Mark Wubben <mark@novemberborn.net>
Relevant code:
ava/lib/snapshot-manager.js
Line 96 in a8c908e
I'd expect something like
label.split(/\n/).map(line => '> ' + line).join('\n')
.Or an option "I would like to format it myself" (Don't insert blockquote or anything - I'll pass the formatted text instead.)
Why:
I'd love to have snapshot reports as human readable and illustrative as possible to serve as a user documentation supplement.
Currently I have to produce not quite readable one-liners, as can be seen here.
I plan to migrate a bigger project to AVA, and it should greatly benefit from the snapshots feature. But I also expect I might need to put more content into labels there.
The text was updated successfully, but these errors were encountered: