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

Improve td.replace error message for incorrect module path #355

Closed
myoffe opened this issue Mar 20, 2018 · 4 comments · Fixed by #363
Closed

Improve td.replace error message for incorrect module path #355

myoffe opened this issue Mar 20, 2018 · 4 comments · Fixed by #363

Comments

@myoffe
Copy link

myoffe commented Mar 20, 2018

Calling td.replace with an incorrect module path prints out the following error:

 TypeError: Cannot read property 'join' of undefined
      at requireAt (node_modules/testdouble/lib/replace/module.js:34:32)
      at default_1 (node_modules/testdouble/lib/replace/module.js:15:21)
      at default_1 (node_modules/testdouble/lib/replace/index.js:10:33)
      at Context.beforeEach (app/users/reset-password.test.js:22:12)

It should print something more informative, like the error message from require:

Error: Cannot find module '/incorrect/path/to/module'

Environment

node v8.10.0
testdouble@3.5.2

@searls
Copy link
Member

searls commented Mar 20, 2018

Absolutely agree. Can you give a specific example of what the correct name was and what was wrong? I ask because there are several different failure paths for module replacement and I want to be clear I understand your case

@myoffe
Copy link
Author

myoffe commented Mar 20, 2018

In my case the failure was caused by replace('./hash'), while the correct path was '../auth/hash'.
This was inside the test file <project root>/app/users/reset-password.test.js

@searls
Copy link
Member

searls commented Mar 25, 2018

This is sort of a dupe of #261 except the message apparently got worse at some point.

searls added a commit that referenced this issue Apr 29, 2018
Fixes #355

add common-tags for nicer heredocs
@searls
Copy link
Member

searls commented Apr 29, 2018

Landed in 3.8.0

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

Successfully merging a pull request may close this issue.

2 participants