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

Display a useful error when withDom fails to find "jsdom". #686

Merged
merged 1 commit into from
Nov 18, 2016

Conversation

indexzero
Copy link
Contributor

Lost a bunch of time on this today because I thought it was a compatibility issue around the new [email protected] release ...

... instead of just my own error of forgetting to install jsdom in a new module. 🙀 🙀 🙀

Hopefully this helps others avoid my mistake. Tried to make the message displayed to users as clear as possible. 💯 ✨ 👍 💪 😼

screen shot 2016-11-16 at 11 32 42 pm

_

Testability is tricky on this since the enzyme module itself depends on jsdom so the error will never be produced. I could introduce proxyquire and force require('jsdom') to throw, but that seemed like overkill. Hopefully the change is obvious and small enough.

if (e.message === "Cannot find module 'jsdom'") {
console.error('[enzyme/withDom] Error: missing required module "jsdom"');
console.error('[enzyme/withDom] To fix this you must run:');
console.error('[enzyme/withDom] npm install jsdom -D');
Copy link
Member

Choose a reason for hiding this comment

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

let's stick to --save-dev rather than using the shortcuts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I didn't feel strongly either way.

@indexzero
Copy link
Contributor Author

@ljharb updated to --save-dev following your feedback.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

LGTM!

it'd be great if you could rebase this down to one commit; if not, I can take care of it for you.

@indexzero
Copy link
Contributor Author

Sure I can rebase and squash it.

@indexzero
Copy link
Contributor Author

All set.

@ljharb ljharb merged commit aaeedcf into enzymejs:master Nov 18, 2016
@ljharb
Copy link
Member

ljharb commented Nov 18, 2016

Thanks!

@indexzero indexzero deleted the withdom-noisy branch November 18, 2016 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants