Type Error with `const`
See original GitHub issueI face myself against a Type Error when trying to rewire a private const
I already have the last version 4.0.1
I used the workaround using let but I would prefer to use const as I don’t want to change my code only for test purposes
Demo: index.js:
const myPromisifiedFunction = promisify(someFunct.ToPromisify) index.test.js:
const myModule = rewire(‘…/myModule’) const myStub = sinon.stub() const revert = myModule.set(‘myPromisifiedFunction’, myStub) And what I get when running tests is: TypeError: Assignment to constant variable. at eval (eval at set (index.js:159:5), <anonymous>:1:19) at Object.set (index.js:159:5) at Object.<anonymous> (test/index.test.js:14:48)
Thanks in advance for any help you could provide !
Edit: I’m aware of the #79 issue, I already commented on it but since it’s closed I thought it would be better to open a new one
Issue Analytics
- State:
- Created 5 years ago
- Reactions:11
- Comments:11 (1 by maintainers)
Top GitHub Comments
I’d like to provide some additional evidence. The issue appears to happen when using the Jest testing library but not with Mocha. I created a git repo to show the issue: https://github.com/Shakakai/jest-rewire-const-error
Here’s a link to the issue in Jest: https://github.com/facebook/jest/issues/6803 I’m not sure which library is responsible.
I’m having the same problem, also using Jest!