babel-plugin-rewire icon indicating copy to clipboard operation
babel-plugin-rewire copied to clipboard

Incompatible with Sinon - Plugin Kills Sinon in Tests

Open krisread opened this issue 8 years ago • 8 comments

Hi!

We noticed that as soon as we installed babel-plugin-rewire our sinon methods like stub() / restore() in our mocha tests are no longer working. I would guess that this plugin is somehow clobbering the functions that handle stubbing and restoring.

krisread avatar Jan 08 '17 19:01 krisread

I have made a helpful test case with a PR for you from my fork:

https://github.com/speedskater/babel-plugin-rewire/pull/175

Please take a look, this shows that using babel-plugin-rewire breaks Sinon stub

krisread avatar Jan 08 '17 22:01 krisread

I'm having the same issue with sinon.stub() having stopped working for named exports after installing babel-plugin-reqire. I was able to work around it by replacing stub() with a combination of __Rewire__() and sinon.spy() for now, but it would be great if the issue could be fixed. Thanks!

apomortsev avatar Jan 17 '17 00:01 apomortsev

@krisread, @apomortsev Thanks for reporting this issue and sorry for the late reply. The issue will be tackled, but this won't happen before mid of march, due to a very tight schedule. Sorry for the inconvenience.

speedskater avatar Feb 13 '17 12:02 speedskater

@speedskater Just curious if there plans for this? Thanks!

goodgec avatar Apr 27 '17 00:04 goodgec

@goodgec sorry for the delay on this issue, but I cannot predict when we will be able to fix this issue, I can only assure, that it won't be forgotten.

speedskater avatar Apr 28 '17 06:04 speedskater

Any update on this?

d1820 avatar Nov 16 '17 23:11 d1820

This plugin looks very promising and we really want to use it. But we got the same issue. The workaround @apomortsev mentioned definitely works, but we have way too many tests to update all sinon.stub usages.

JingyuZ avatar May 03 '18 21:05 JingyuZ

you could look at overriding the stub with prototype that injected the workaround above.. just an idea

d1820 avatar May 03 '18 21:05 d1820