-
Notifications
You must be signed in to change notification settings - Fork 1.4k
*.snap
files content should be the same regardless of test execution order
#2311
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
Oh interesting, I've never noticed that before. We should sort by test title, like we do for the Markdown files: Line 107 in 9757190
|
We're looking at sorting by declaration order instead, see #2324. That said, this issue is primarily about having a stable sort order, and we could still use test titles for that. |
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]>
Sweet, thanks! |
Description
When a test file has several parallel async tests and each of those tests call
t.snapshot()
, the resulting*.snap
file is non-deterministic. The contents of the*.snap
file depends on the order in which tests finished.In such cases, tests pass correctly. However the
*.snap
files contents keep being updated, which means they are shown as dirty files bygit status
and they result in merge conflicts, especially in PRs.Making
*.snap
file contents independent of test execution order would solve this issue.Test Source
test.js
Running
ava -u
on this file produces different*.snap
depending on whetherone
ortwo
finishes first.Command-Line Arguments
Copy your npm build scripts or the
ava
command used:Environment
Tell us which operating system you are using, as well as which versions of Node.js, npm, and AVA. Run the following to get it quickly:
The text was updated successfully, but these errors were encountered: