Closed jhorneman closed 9 years ago
Thanks for setting up the test case, that makes my life much easier! I'll take a look when I can.
I haven't had time to set this up yet but looking at the code - have you tried switching exports
to module.exports
? Rewireify assigns the __get__
and __set__
properties on module.exports
which takes precedence over exports
(see here for more info).
I've had a minute and managed a proper look. Downgrading Rewireify to 0.2.0 in your example app works. This version of Rewireify bundled an old version of the injected __set__
method from Rewire so this may be a bug may be within the Rewire dependency or Rewireify's integration with it.
Thanks! (module.exports made no difference.)
By the way, I also added the issue over at Rewire: https://github.com/jhnns/rewire/issues/70
I'm glad there is a workaround at least. I was going crazy since this seemed like such a common use case and I wondered what I was doing wrong.
Are you able to run the test runner successfully in your browser (rather than through headless PhantomJS)? Mocking the methods of dependencies is covered in the test suite and is working as expected when in Chrome and Firefox.
Function.prototype.bind
is undefined in PhantomJS 1.x (See https://github.com/ariya/phantomjs/issues/13107)
Thanks for taking a look @jhnns and figuring it out =D
Thank you for figuring out what the problem was.
I hope this is the right repo.
When I call
__set__
on a module, to mock a function it requires from another module, I get the following error message:I've made a minimal reproduction repo here: [https://github.com/jhorneman/karma-browserify-repro]().
Just run npm install, then npm run test.
I'm using Karma, Jasmine, Browserify, and Rewireify, under Windows 7.
Please let me know if you need more information.