question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Make `-u` option more user friendly and less error-prone

See original GitHub issue

šŸš€ Feature Proposal

Basically after seeing this interactive snapshot updater I think it would make sense if the -u option were to show a prompt to update snapshots similar to running in interactive mode.

Additionally I would propose a -U (or other unused flag) to be equal to the current behavior

Motivation

I think snapshot testing is awesome! But Iā€™ve been having a hard time convincing a coworker and heā€™s got a valid point about the -u option, itā€™s entirely too easy to update all the snapshots and let stuff slip in. If the -u option were to use the interactive prompts for updating with diff views and the -U option were to clearly state itā€™s an ā€œunsafeā€ option and do a y/n confirm I think itā€™d make the user experience around snapshot testing more explicit.

Pitch

The core Jest experience shouldnā€™t make it easy to shoot yourself in the foot like the current -u option does.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
thymikeecommented, May 8, 2018

I think it actually makes sense to make updating all the snapshots a bit harder, especially that we now can update snapshots one by one, but only in watch mode. We just need to figure out the best way to do it. How about this flow:

  1. [watch mode] Press u
  2. Jest prompts:
You're about to update *all* snapshots
> Press `u` or `y` to continue
> Press `n` or `esc` to abort
> Press `i` to update snapshots interactively

I think itā€™s nice to be able to continue by pressing u once more, just not be too annoying.

2reactions
rickhanloniicommented, May 8, 2018

I guess I donā€™t really see this as a foot-gun if youā€™re following best practices

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Prone Improves Java Code by Detecting Common ...
Error Prone, a Java compiler plugin open sourced by Google, performs static analysis during compilation to detect bugs or possibleĀ ...
Read more >
Streamlining large-scale Java development using Error Prone ...
For more info on the next Devoxx UK event www.devoxx.co.ukUsing static analysis to spot bugs in your code has become a staple of...
Read more >
Error Prone
We use Error Prone in Google's Java build system to eliminate classes of serious bugs from entering our code, and we've open-sourced it,...
Read more >
producing high-quality and consistent Java code ā€“ Join Picnic
Introducing Error Proneā€‹ā€‹ At Picnic, we have adopted Error Prone, a Java compiler plugin created by Google. It's capable of automated checking and...
Read more >
Preventing User Errors: Avoiding Unconscious Slips
However, it's even better to prevent users from making errors in the first ... The answer is to redesign the system to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found