-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Update documentation on automocking #5630
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Codecov Report
@@ Coverage Diff @@
## master #5630 +/- ##
==========================================
- Coverage 60.94% 60.89% -0.05%
==========================================
Files 215 215
Lines 7335 7319 -16
Branches 4 3 -1
==========================================
- Hits 4470 4457 -13
+ Misses 2864 2861 -3
Partials 1 1
Continue to review full report at Codecov.
|
docs/Configuration.md
Outdated
}); | ||
``` | ||
|
||
If you are introducing Jest to a large organization with an existing codebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's a good recommendation now, as then switching to "automock": false
will be painful. We should kill that paragraph imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with rolling back this guidance. You are right.
docs/JestObjectAPI.md
Outdated
@@ -49,9 +49,43 @@ will be cleared and will never have the opportunity to execute in the future. | |||
|
|||
Disables automatic mocking in the module loader. | |||
|
|||
> See `automock` section of [configuration](Configuration.md) for more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you link to the exact place, e.g. Configuration.md#automock-boolean
?
docs/JestObjectAPI.md
Outdated
|
||
```js | ||
// __tests__/disableAutomocking.js | ||
jest.disableAutomock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be good to move this below import, babel-jest
will hoist that.
docs/JestObjectAPI.md
Outdated
@@ -75,6 +109,35 @@ Enables automatic mocking in the module loader. | |||
|
|||
Returns the `jest` object for chaining. | |||
|
|||
> See `automock` section of [configuration](Configuration.md) for more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
direct link
docs/JestObjectAPI.md
Outdated
|
||
```js | ||
// __tests__/genMockFromModule.test.js | ||
import utils from '../utils'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this, as it's not necessary and redefining it below will throw error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some notes inlined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it's good to go now. One last thing could be removing the // implementation
comment, because it's not necessary.
Please remove it :)
One more thing, a changelog entry! 😄 |
CHANGELOG.md
Outdated
@@ -2,6 +2,8 @@ | |||
|
|||
### Fixes | |||
|
|||
* `[docs]` Update automatic mocks documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add this under ### Chore & Maintenance
section below Fixes
Ok done 👍 |
check this for a sample of manual and automatic mock |
using jest.mock( ' ' ) - creates a automatic mock whereas manual mocks are created by making mock functions in a seperate mock folder .Iam a newbie and its what i interpret upon first reading.. |
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. |
Summary
Updated sections in documentation:
automock
genMockFromModule
enableAutomock
anddisabledAutomock
Added few example with tests related to changes that made in documentation.
Fixes #5290
Test plan