You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use Rewire together with Karma and Jasmine. Generally, it works well. However, as soon as I call __Rewire__, Jasmine's this becomes undefined.
I use
describe('Working test',()=>{beforeEach(()=>{this.variable='a value';});it('should be able to read the variable bound to userContext',()=>{expect(this.variable).not.toBe(undefined);expect(this.variable).toBe('a value');});});
However, if I rewire as follows:
describe('Failing test',()=>{beforeEach(()=>{this.variable='a value';rewireAPI.__Rewire__('functionToRewire',()=>{});});it('should be able to read the variable bound to userContext',()=>{expect(this.variable).not.toBe(undefined);expect(this.variable).toBe('a value');});});
I get the following error: TypeError: undefined is not a function (evaluating '_get__('rewireAPI').__Rewire__('functionToRewire', function () {})')
I have seen #109 but I believe this issue is different as I can use Rewire perfectly fine as long as I refrain from using this.
You can find a minimal example here. The error is unrelated to Mocha, which I have just included for increasing readability of the test results.
The text was updated successfully, but these errors were encountered:
Hi all,
I'm trying to use Rewire together with Karma and Jasmine. Generally, it works well. However, as soon as I call
__Rewire__
, Jasmine'sthis
becomesundefined
.I use
and import it as follows:
When I'm assigning to
this
it works:However, if I rewire as follows:
I get the following error:
TypeError: undefined is not a function (evaluating '_get__('rewireAPI').__Rewire__('functionToRewire', function () {})')
I have seen #109 but I believe this issue is different as I can use Rewire perfectly fine as long as I refrain from using
this
.You can find a minimal example here. The error is unrelated to Mocha, which I have just included for increasing readability of the test results.
The text was updated successfully, but these errors were encountered: