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

Add snapshot testing FAQs #3425

Merged
merged 2 commits into from
May 2, 2017
Merged

Conversation

MicheleBertoli
Copy link
Contributor

Summary

There are a few common misconceptions around snapshot testing that always come out when engineers are approaching this technique for the first time.
The new "frequently asked questions" section aims to answer the most common ones, giving clarity to the engineers.
These questions have been collected during conferences, meetups and within issues and PRs.

Test plan

@codecov-io
Copy link

codecov-io commented Apr 30, 2017

Codecov Report

Merging #3425 into master will increase coverage by 0.87%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3425      +/-   ##
==========================================
+ Coverage   64.04%   64.92%   +0.87%     
==========================================
  Files         177      176       -1     
  Lines        6570     6514      -56     
  Branches        4        5       +1     
==========================================
+ Hits         4208     4229      +21     
+ Misses       2361     2283      -78     
- Partials        1        2       +1
Impacted Files Coverage Δ
...ests/coverage_report/not-required-in-test-suite.js 0% <0%> (-20%) ⬇️
packages/jest-cli/src/watch.js 74.19% <0%> (-1.93%) ⬇️
packages/jest-cli/src/generateEmptyCoverage.js 88.88% <0%> (-1.12%) ⬇️
packages/jest-config/src/index.js 25% <0%> (-1.09%) ⬇️
packages/jest-runtime/src/index.js 75% <0%> (-0.97%) ⬇️
packages/jest-cli/src/TestNamePatternPrompt.js 94.33% <0%> (-0.49%) ⬇️
packages/jest-jasmine2/src/reporter.js 85.29% <0%> (-0.43%) ⬇️
packages/jest-cli/src/TestPathPatternPrompt.js 98.07% <0%> (-0.17%) ⬇️
packages/jest-matchers/src/index.js 95.23% <0%> (-0.17%) ⬇️
packages/jest-mock/src/index.js 91.81% <0%> (-0.04%) ⬇️
... and 37 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0817d64...490ecc2. Read the comment docs.


As you've learned, snapshot testing was built to make it easier to write tests for React and React Native. Check out the [React tutorial](/jest/docs/tutorial-react.html) and the [React Native tutorial](/jest/docs/tutorial-react-native.html) to get started with snapshot testing on your React or React Native application.
Snapshot files must always represent the current state of the modules they are covering.
Therefore, if you are merging two branches and encounter a conflict in the snapshot files, the best solution is updating the snapshots to the latest version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@cpojer cpojer merged commit d8df88f into jestjs:master May 2, 2017
@cpojer
Copy link
Member

cpojer commented May 2, 2017

I made a few small adjustments but this is great, thanks for the help @MicheleBertoli.

@MicheleBertoli
Copy link
Contributor Author

Awesome, thanks @cpojer.

@MicheleBertoli MicheleBertoli deleted the snapshot-testing-faq branch May 2, 2017 12:02
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
* Add snapshot testing FAQs

* Update SnapshotTesting.md
@github-actions
Copy link

This pull request 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 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants