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

td.replace CJS module-replacement gives bad message if item is not requireable #261

Open
searls opened this issue Jun 14, 2017 · 0 comments

Comments

@searls
Copy link
Member

searls commented Jun 14, 2017

I had a depended-on module X that was in a not-requireable state because of a typo in one of its import statements. The symptom given to me by TD when I tried to td.replace() said module from its user's test was "module X not found".

This was not a useful message, because it sent me on a hunt to find a ../../ path screw-up, when the real root cause was that quibble failed to require it, so it just blew up. It's necessary for dependencies' to require cleanly so we can imitate their functions/constructors/etc, but the message should indicate that's what failed, not that the file was missing.

  stacktrace: Error: Cannot find module '../../src/wrap/log' from '/Users/justin/code/testdouble/testdouble.js' 
    at Function.module.exports [as sync] (/Users/justin/code/testdouble/testdouble.js/node_modules/resolve/lib/sync.js:37:15)
    at requireAt (/Users/justin/code/testdouble/testdouble.js/node_modules/testdouble/lib/replace/module.js:39:38) 
    at exports.default (/Users/justin/code/testdouble/testdouble.js/node_modules/testdouble/lib/replace/module.js:11:19) 
    at exports.default [as replace] (/Users/justin/code/testdouble/testdouble.js/node_modules/testdouble/lib/replace/index.js:9:29) 
    at undefined.beforeEach (/Users/justin/code/testdouble/testdouble.js/unit/when/ensure-rehearsal.test.js:4:14) 
    at /Users/justin/code/testdouble/testdouble.js/node_modules/teenytest/lib/plugins/callbackify.js:15:17 
    at runX (/Users/justin/code/testdouble/testdouble.js/node_modules/teenytest/lib/plugins/wrap.js:22:7) 
    at Object.userFunction [as wrap] (/Users/justin/code/testdouble/testdouble.js/node_modules/teenytest/plugins/uncaught-exception.js:16:9) 
    at callable (/Users/justin/code/testdouble/testdouble.js/node_modules/teenytest/lib/plugins/wrap.js:29:24) 
    at runX (/Users/justin/code/testdouble/testdouble.js/node_modules/teenytest/lib/plugins/wrap.js:22:7) ```
@searls searls added the bug label Jun 14, 2017
@searls searls changed the title td.replace CJS module-replacement fails if item is not requireable td.replace CJS module-replacement gives bad message if item is not requireable Jun 14, 2017
@jasonkarns jasonkarns added this to Backlog in Test Double Trouble Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

1 participant