-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Store snapshots by test declaration order #2324
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
Comments
Yup, we should do this. Thanks for bringing it up. It should be possible to assign incremental IDs as tests are declared, and use those to sort the snapshots. |
ooh - that's so interesting that you mention incremental ids. Could that also be used to order the verbose reports on the CLI? |
Yea, but we need to rewrite the reporters anyhow. |
as part of this issue? I'd be interested understanding the thinking behind changes to reporters. A quick search didn't reveal anything obvious. |
No.
See #2217. |
Ensures that *.snap files are deterministic by sorting entry blocks by the hash of their test name or id. Ensures that *.md snapshot report files are sorted in as close to declaration order as is reasonably possible. Closes #2311 Closes #2324 Co-authored-by: Sindre Sorhus <[email protected]> Co-authored-by: Mark Wubben <[email protected]>
Description
Please consider not sorting snapshots when they are recorded - especially to the markdown version.
My use case
I use ava with snapshots for testing "pure-ish" functions that are composed into larger workflows.
Meaning while the functions have side effects, they are testable with input/output expectations.
Snapshots are ideal for this.
However, since these are functions with side-effects, for proper testing, they have to be run in serial order to simulate the workflow. This allows the functions to be tested in isolation, while
building upon previous steps. The cost of setup of partial workflows is significant enough that it's not practical to think of think of running each function as a test suite.
Snapshots are a great way to capture the expectations and track deviations over time.
However in snapshot-manager.js these recordings are being sorted in title-order.
Now my ability to manually inspect the output is severely impacted, requiring all kinds of
up-and-down scrolling. Some of these are API calls with 10s or even 100s of lines of data.
Sometimes, out of sheer frustration, I put numbers in the test titles, but that turns out to cause
other problems in complex refactoring/requirement-change situations.
Options I can think of:
Strikes me that option 5 would seem to solve all problems (including #2311?), allow for side-by-side scrolling of test file and markdown, without requiring any configuration.
Really unsure of the implementation complexity though.
The text was updated successfully, but these errors were encountered: