Closed weilu closed 10 years ago
There is no way proxyquire works for browser code since it relies on require
extensions`.
Do these tests run client side or server side?
The tests run on server side after browserifying through build.js
I dug a bit deeper and believe it's a variable hoisting issue. Here's a snippet of the browserified code:
},{}],17:[function(require,module,exports){
(function (Buffer){
/* proxyquireify injected requires to make browserify include dependencies in the bundle */;
require('../');
/*proxyquireify override */;
var require_ = require;
var require = require('proxyquireify').proxy(require_);
The undefined is not a function
error was thrown from the line require('../');
because require is redeclared and assigned later which causes it to become undefined before the assignment. Dropping the var on this line fixed it for me. I wanted to PR it but couldn't run the client side tests therefore couldn't add tests for it. @thlorenz thoughts?
Could you please try to see if that is fixed in the latest version (some major changes, so hopefully they addressed your changes).
I tried @jhiesey's branch. It fixes the issue reported here.
If I use proxyquire without browserify and proxyquireify (uncomment line 2 in
test/index.js
), my test passes.I've put together the code above in a repo: https://github.com/weilu/test-proxyquireify The error can be reproduced by running
npm test