We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Maybe I'm doing something wrong, I don't know... I'm trying to make an injection, but it seems it's not working.
I tried Stackoverflow before with no success: https://stackoverflow.com/questions/54443582/rewire-mocha-how-to-inject-a-function
So I'm trying to inject a mocked function in a module using Rewire. I have a LotsRepo module with
const _incLot = async (params) => { // ... } exports.incLot = _incLot
Then, following this example, in a Mocha test I'm using:
let rewire = require('rewire') var injections = { _incLot: async (params) => { throw new Error('mocked: findOneAndUpdate fake error!') } } const rewiredLotsRepo = rewire('./lotsRepo.js', null, injections)
And later, on an 'it' part, I'm calling:
let lot = await rewiredLotsRepo.incLot(params)
I was expecting to get the error. But instead, it's accessing the original incLot. What am I doing wrong?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Maybe I'm doing something wrong, I don't know... I'm trying to make an injection, but it seems it's not working.
I tried Stackoverflow before with no success: https://stackoverflow.com/questions/54443582/rewire-mocha-how-to-inject-a-function
So I'm trying to inject a mocked function in a module using Rewire.
I have a LotsRepo module with
Then, following this example, in a Mocha test I'm using:
And later, on an 'it' part, I'm calling:
let lot = await rewiredLotsRepo.incLot(params)
I was expecting to get the error. But instead, it's accessing the original incLot. What am I doing wrong?
The text was updated successfully, but these errors were encountered: