-
-
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
docs: runnable example of the for Each test #13428
Conversation
Hi, Perhaps the documentation is written for (more) experienced programmers or for readers who nicely walked through the tutorial but for past me It would have been helpful to have a runnable example. Therefore my suggested improvements so that one can copy paste it to their editor.
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.
Thanks. That is good idea.
Please fix docs for all versions and the Next version too.
Also run yarn lint
(;
Hi @Jeroendevr! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign 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 to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
I will try to adjust to your suggestions, thanks for the heads up about linting. I am no experienced GitHub user so after my edited PR, you should guide me how to apply this to all versions.
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Co-authored-by: Tom Mrazauskas <tom@mrazauskas.de>
Co-authored-by: Tom Mrazauskas <tom@mrazauskas.de>
Thanks. The changes look good, but you have to run Prettier (through No sure why you added a note about new PR. All versioned docs can be updated in one go (one PR). Just make the same change in all files from |
Thanks for pointing out the different docs locations, and the linting, and the fact that is should be within one PR. |
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.
Thanks. I left few more comments.
Some how I was sure that yarn lint
runs Prettier as well, but it doesn’t. You should run yarn lint:prettier
additionally. It will add one missing space.
By the way, docs/MockFunctions.md
file is missing. Same changes should be made there too. The rest you found (;
// The function was called with a certain `this` context: the `element` object. | ||
expect(someMockFunction.mock.contexts[0]).toBe(element); | ||
|
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.
Hm.. I guess these are accidental changes. Jest v25 does not have mock.contexts
it was introduced recently. That is why it appears only in the docs of later versions.
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.
Ah my bad. Glad you paid good attention to it.
@@ -17,41 +17,49 @@ function forEach(items, callback) { | |||
callback(items[index]); | |||
} | |||
} | |||
module.exports = forEach; |
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.
One more thought. What about using ESM syntax here? The examples below written in ESM: https://jestjs.io/docs/next/mock-functions#mocking-modules
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.
ESM syntax is then export forEach;
?
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.
It is:
export function forEach(items, callback) {
// etc ...
And instead of const forEach = require('./foreach');
:
import {forEach} from './forEach';
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.
Ah I thought there were two ways to export a module.
One as you describe it. Add export
before the function declaration and one where you can group all the functions, classes you want to export together (for example at the bottom)
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.
Ok if v25 is acceptable I'll change the others as well. Thanks for learning on the job.
Co-authored-by: Tom Mrazauskas <tom@mrazauskas.de>
Ok thanks for the feedback, added the two empty lines. Also updated along all the versions. Hopefully done it well. 🫣🤗 |
Thanks. All looks good to me. Now we have to wait for the maintainer to take a look. |
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.
great stuff, thanks!
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. |
Hi, Perhaps the documentation is written for (more) experienced programmers or for readers who nicely walked through the tutorial but for past me It would have been helpful to have a runnable example. Therefore my suggested improvements so that one can copy paste it to their editor.