vscode-jest icon indicating copy to clipboard operation
vscode-jest copied to clipboard

Remove obsolete snapshots

Open rptrk opened this issue 7 years ago • 4 comments

Environment

  1. node -v: v8.4.0

  2. npm -v: 5.3.0

  3. npm ls react-scripts (if you haven’t ejected): N/A

  4. Operating system: macOS High Sierra Version 10.13.3

Steps to Reproduce

  1. Open a test file that contains a snapshot expectation
  2. Add a snapshot expectation (this will get generated)
  3. Remove snapshot expectation (this will not get removed)

Expected Behavior

Removal of snapshot expectation would remove obsolete snapshot (or a dialog would appear asking if I'd like to update my snapshots and remove obsolete)

Actual Behavior

Removal of snapshot expectation does not remove obsolete snapshot (or show a dialog asking if I'd like to update my snapshots and remove obsolete)


Am I misunderstood? It seems that if I add a new snapshot expectation, I will be prompted to update my snapshots and this will remove any obsolete; however, this is not an ideal workflow.

I started using this extension to replace the need to run my tests in the terminal, but it seems I may need to still do this in the case where I have obsolete snapshots.

rptrk avatar Mar 07 '18 22:03 rptrk

Makes sense, want to try take a look at adding this?

orta avatar Mar 07 '18 22:03 orta

+1

ctoppel avatar Nov 20 '18 22:11 ctoppel

I just run jest --updateSnapshot and that flag removes obsolete snapshots

steven-pribilinskiy avatar Nov 22 '18 22:11 steven-pribilinskiy

When jest is running, you can press W, see the options, press U.

Watch Usage › Press u to update failing snapshots.

Or go to the snapshots folder in the same folder of your test and delete them.

estevanpedro avatar Oct 21 '21 09:10 estevanpedro

@estevanpedro

This is not realy a solution no. The files still remain ...

doozMen avatar Jan 23 '23 15:01 doozMen

This is a really old thread. Since v5.1, you should be able to run update snapshot (via test menu) to remove obsolete snapshots.

Close this as this feature is available now.

connectdotz avatar Jan 25 '23 03:01 connectdotz