Skip to content
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

Interactive snapshot update issue with nested sibling describe blocks #6625

Closed
noinkling opened this issue Jul 5, 2018 · 7 comments
Closed
Assignees

Comments

@noinkling
Copy link

noinkling commented Jul 5, 2018

Following on from #6611, #6485 and the fix for that issue in #6579. Probably not directly related to that issue.

🐛 Bug Report

Minimal example structure:

  • describe
    • describe
      • test containing .toMatchSnapshot()
    • describe
      • test containing .toMatchSnapshot()

When entering interactive snapshot update mode in Jest 23.3.0, the prompt for the first failed snapshot says that all the other snapshots (for other tests) are "obsolete" and that they will be removed. Example output from my actual project:

Snapshot Summary
 › 1 snapshot failed from 1 test suite. Inspect your code changes or press `u` to update them.
 › 6 snapshots obsolete from 1 test suite. To remove them all, press `u`.

...

Interactive Snapshot Progress
 › 4 snapshots remaining

Upon pressing u that's what happens: the one snapshot gets updated but the rest get deleted (including two that passed). Then when it moves onto the next failing snapshot, it says that no previous snapshot exists (since it was just deleted) and that the the one that was just updated is obsolete. Pressing u again does more or less the same thing: the current snapshot gets written, and the one that was updated just before is deleted. In effect it's only allowing allowing the storage of a single snapshot when going through interactive mode.

Doing a standard snapshot update with u/-u works as expected, it writes all the snapshots.

Link to repl or repo (highly encouraged)

https://github.com/noinkling/jest-bug-repro

With Jest 23.0.0 - 23.3.0 (can npm install), run npm test or jest --watchAll directly, then press i to enter interactive mode.

Run npx envinfo --preset jest

  System:
    OS: Linux 4.4 Ubuntu 16.04.4 LTS (Xenial Xerus)
    CPU: x64 Intel(R) Core(TM)2 Quad CPU    Q9400  @ 2.66GHz
  Binaries:
    Node: 10.5.0 - /usr/bin/node
    Yarn: 1.7.0 - /usr/bin/yarn
    npm: 6.1.0 - /usr/bin/npm

I'm using WSL.

@noinkling
Copy link
Author

noinkling commented Jul 6, 2018

This behaviour was introduced in 23.0.0

Before that (v22.4.2) the behaviour was to group all 3 snapshots in the linked example repo together (and therefore update them together). I'm not suggesting that behaviour was more desirable than the intended improvements in v23, just noting that's what changed when this issue was introduced.

@rickhanlonii
Copy link
Member

Probably broken by #6579

@noinkling
Copy link
Author

@rickhanlonii Sorry I should have made it more clear: this issue also exists in 23.0.0, so I don't think it's directly related to #6579.

@rickhanlonii
Copy link
Member

Ah, ok thanks 👍

@noinkling
Copy link
Author

This issue seems to be fixed in the latest version (23.4.0), no issues with "obsolete" snapshots any more.

However the overall process is a little slow if there are more than a couple of snapshots to go through, which seems to be due to reinitializing(?) the suite for each snapshot. Is this intended?

@noinkling
Copy link
Author

noinkling commented Oct 3, 2018

I'll close this as I think the last point about the slowness is just a consequence of design, and it's not strictly related to the original issue.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants