-
Notifications
You must be signed in to change notification settings - Fork 5
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
WIP ⚠ configure jest with enzyme #105
base: master
Are you sure you want to change the base?
Conversation
@@ -67,6 +67,7 @@ | |||
"babel-jest": "24.9.0", | |||
"babel-loader": "^8.0.6", | |||
"babel-plugin-istanbul": "6.0.0", | |||
"check-prop-types": "^1.1.2", |
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.
TODO: discuss with the team:
Seems like a helpful idea to verify prop-types on PUBLIC libraries.
@@ -59,6 +59,9 @@ FileForm.propTypes = { | |||
submitText: PropTypes.string, | |||
/** Function run when submit button is clicked */ | |||
onSubmit: PropTypes.func.isRequired, | |||
branch: PropTypes.string, | |||
filepath: PropTypes.string, | |||
defaultContent: PropTypes.string, |
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.
NOTE: there were a few missing proptypes 👍
jest.enzyme.config.js, line 1 at r1 (raw file):
For now, I think there is a different If this PR is going to be approved, we can probably refactor a single |
package.json, line 32 at r1 (raw file):
For now, there are two ways to invoke jest. But if this PR is going to be approved, maybe we can refactor into a single (combined) script |
mocks/fileMock.js, line 1 at r1 (raw file):
see |
src/components/file/FileForm.js, line 22 at r1 (raw file):
Several |
mocks/FileForm.test.js, line 27 at r1 (raw file):
TODO: can we look at these tests? They look helpful to me.
|
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.
Reviewed all commit messages.
Reviewable status: 0 of 6 files reviewed, 5 unresolved discussions (waiting on @rady-ben)
I added the new script because I saw this error message when I run the existing script error Command failed with exit code 1. and the script stops and exits. and there in no watch, jest doesn't refreshes when I updated the tests that’s why I had the idea to add new command with the new tests. |
__mocks__/FileCard.test.js
Outdated
const previewButton = findByAttribute(wrapper, 'previewButton'); | ||
previewButton.simulate('click'); | ||
expect(mockSetPreview).toBeCalledWith(false); | ||
// NEED HELP |
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.
@ancientTexts-net
in this function I am testing the initial value to be true
and the and when the user click on the button I test that that the setPreview
is call with the false
as param. which describe the switch from true to false.
but I don't know how to set realy the state on the component to false
so I will be able to test the switch from false to true.
I found that in a class component we use something like this
wrapper.instance().setPreview(false)
I am looking for an equivalent for the hooks
onEdit={setMarkdown} | ||
editable={!!authentication} | ||
editable={isAuthenticated} | ||
data-test="blockEditable" |
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.
@ancientTexts-net
how can I simulate the onEdit event with jest BlockEditable.simulate('onEdit', mock Event);
doesn't work
This change is