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

Inline snapshots: do not indent empty lines. #8277

Merged

Conversation

@scotthovestadt
Copy link
Contributor

scotthovestadt commented Apr 5, 2019

Summary

Problem as reported by @zertosh :

One issue I found though is that if your output has new lines somewhere, they become just indented whitespace - as expected. But most editors have automatic trailing whitespace removal, so you end up changing the test just by saving.

The obvious concern here is that, if for whatever reason a snapshot is relying on whitespace on a certain line, we don't want to impact that... even if some editors are going to automatically remove it.

To resolve, I've just stopped indenting empty lines IF they are completely empty.

Test plan

  • Added unit test to verify behavior. The test previously fails, it now passes.
  • Added e2e tests for behavior.
Copy link
Collaborator

thymikee left a comment

👍

@scotthovestadt scotthovestadt merged commit 01044da into facebook:master Apr 5, 2019
10 of 11 checks passed
10 of 11 checks passed
ci/circleci: test-jest-circus Your tests failed on CircleCI
Details
ci/circleci: lint-and-typecheck Your tests passed on CircleCI!
Details
ci/circleci: test-browser Your tests passed on CircleCI!
Details
ci/circleci: test-node-10 Your tests passed on CircleCI!
Details
ci/circleci: test-node-11 Your tests passed on CircleCI!
Details
ci/circleci: test-node-6 Your tests passed on CircleCI!
Details
ci/circleci: test-node-8 Your tests passed on CircleCI!
Details
ci/circleci: test-or-deploy-website Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details
facebook.jest #20190405.4 succeeded
Details
@zertosh

This comment has been minimized.

Copy link
Member

zertosh commented Apr 6, 2019

Any chance this can go out in a patch release?

@SimenB

This comment has been minimized.

Copy link
Collaborator

SimenB commented Apr 6, 2019

Seems like a bug in those editors - removing trailing whitespace in a template literal changes the string. In this case (snapshots), it doesn't really matter or course :)

@scotthovestadt

This comment has been minimized.

Copy link
Contributor Author

scotthovestadt commented Apr 6, 2019

@zertosh Will push out soon.

@SimenB Yeah, I agree it's a little strange to have editors changing things inside of template literals, but I'm able to reproduce it

@alfaproject

This comment has been minimized.

Copy link

alfaproject commented Apr 24, 2019

Also, git does that as well if you configure it to do so, which I usually do

@zertosh

This comment has been minimized.

Copy link
Member

zertosh commented Apr 28, 2019

Can I bug someone to please do a release with this fix? :)

@scotthovestadt

This comment has been minimized.

Copy link
Contributor Author

scotthovestadt commented Apr 28, 2019

@zertosh Yeah, plan to do shortly... but FYI at Facebook we're now on master branch so you should have it there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.