Skip to content
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

Expand Jest setup instructions. #33

Merged
merged 1 commit into from
Jul 11, 2016
Merged

Expand Jest setup instructions. #33

merged 1 commit into from
Jul 11, 2016

Conversation

carlbaron
Copy link
Contributor

@carlbaron carlbaron commented Jul 11, 2016

#32

I ran into some cryptic error messages when I didn't add enzyme and jasmine-enzyme to jest's unmocked module list.

This PR adds an explicit mention in the jest setup docs that you need to unmock these modules.

@blainekasten

### Jest
If you are using [jest](https://facebook.github.io/jest/), the simplest setup
is to use jest's `setupTestFrameworkScriptFile` config. You'll also need to
tell jest to unmock `react`, `enzyme`, and `enzyme-jest`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enzyme-jest ? do you mean jasmine-enzyme ?

Also. I've never experienced needing jasmine-enzyme in the unmocked module paths. From having a slight understanding of jest's internals, I don't think it would ever be necassary. Could you try removing jasmine-enzyme from your unmockedModulePathPatterns and see if it fails?

Copy link
Contributor Author

@carlbaron carlbaron Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops sorry, that should indeed be jasmine-enzyme.

I get the following error when removing jasmine-enzyme from unmockedModulePathPatterns

TypeError: expect(...).toHaveText is not a function

This is of course when using the .toHaveText() assertion. I get the same kind of error message with any of the jasmine-enzyme assertions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. I bet it's working for me because I put just "enzyme" in my unmocked path. Which regex matches "jasmine-enzyme". But it's probably better for the docs to be explicit.

* `enzyme` and `jasmine-enzyme` must be unmocked.
@carlbaron
Copy link
Contributor Author

@blainekasten Makes sense, I rebased the commit to incorporate the changes and fix the typo mentioned earlier.

@blainekasten blainekasten merged commit e226a5a into enzymejs:master Jul 11, 2016
@blainekasten
Copy link
Collaborator

Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants