Document class mocks#5383
Conversation
SimenB
left a comment
There was a problem hiding this comment.
Thanks for the PR! I'll read through it in a bit, but could you first run yarn lint:md and fix the lint issues reported by CI?
/home/circleci/jest/docs/Es6ClassMocks.md
133:5 error 'mockPlaySoundFile' is never reassigned. Use 'const' instead prefer-const
244:5 error 'mockPlaySoundFile' is never reassigned. Use 'const' instead prefer-const
286:5 error 'mockPlaySoundFile' is never reassigned. Use 'const' instead prefer-const
Codecov Report
@@ Coverage Diff @@
## master #5383 +/- ##
=======================================
Coverage 61.32% 61.32%
=======================================
Files 205 205
Lines 6925 6925
Branches 3 3
=======================================
Hits 4247 4247
Misses 2677 2677
Partials 1 1Continue to review full report at Codecov.
|
SimenB
left a comment
There was a problem hiding this comment.
This looks great! Thank you so much for taking the time to write it!
|
Thanks so much for sending a great guide to our documentation, this is always appreciated. We are looking forward to many more PRs from you to improve Jest's documentation :) |
|
For anyone reading this comment, I have setup a GitHub repository to test mocking modules and classes. It is based on the principles described in the document, but it covers both default and named exports. |
|
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. |
This is my first PR. Feedback and suggestions are very welcome!
Summary
Documents in detail how to mock an ES6 class. Without this guide, it's hard to find the docs that exist for mocking an ES6 class, and also there is no explanation of how it works.
Resolves issue #5023
Test plan
ran

yarn startin thewebsitedirectory.Browsed to localhost:3000 using Firefox and Chrome
Ensured that new guide "ES6 Class Mocks" appears in the sidebar.
Ensured that clicking that sidebar link loads the new guide.
Tested all links in the content, which are links to other pages of the jest docs.