WIP ⚠ configure jest with enzyme #105
WIP ⚠ configure jest with enzyme #105rady-ben wants to merge 18 commits intounfoldingWord:masterfrom
Conversation
| "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.
TODO: discuss with the team:
Seems like a helpful idea to verify prop-types on PUBLIC libraries.
| onSubmit: PropTypes.func.isRequired, | ||
| branch: PropTypes.string, | ||
| filepath: PropTypes.string, | ||
| defaultContent: PropTypes.string, |
There was a problem hiding this comment.
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.
|
ancientTexts-net
left a comment
There was a problem hiding this comment.
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. |
| const previewButton = findByAttribute(wrapper, 'previewButton'); | ||
| previewButton.simulate('click'); | ||
| expect(mockSetPreview).toBeCalledWith(false); | ||
| // NEED HELP |
There was a problem hiding this comment.
@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.
@ancientTexts-net
how can I simulate the onEdit event with jest BlockEditable.simulate('onEdit', mock Event); doesn't work
This change is