Closed wuyiqun0718 closed 7 years ago
I don't quite follow.. When you call mockery.enable()
it will then mock only the modules that are set with mockery.registerMock
. It doesn't mock everything, only what is sent to that method.
OK, I got too many require calls in my file. I tried different ways to mock them and it kept giving me different errors. So I thought it's because I didn't mock some packages. And since I got the confirmation from you, I just tried to modify my mock module again and it worked! Apparently I don't need to pass parameters to my mock functions when do registerMock.
Please close this, thank you for the answer!
Glad you got it working..
Hi all, I'm very new to unit testing, and I'm trying to get familiar with these mock libraries.
I tried to not use the enable function when setup and only do registerMock for some packages, but it's not working for me. I'm guessing the enable function is a must, so is there anyway to just register mock for some module instead of intercepting all of them? I also tried rewire, but apparently it can't intercept any require calls.