-
-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
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
Using Sinon with Webpack and Babel fails on import #830
Comments
Are you using sinon from npm? Which version? |
This webpack issue covers the same thing, without a solid solution and lots of working around the problem: webpack/webpack#304. It's not the exact same error, but basically the same problem. |
Yes I am using the latest npm version. |
Just for the sake of history, it would be great if you could provide the version number. Future readers of this thread would then know which version you were talking about. |
Yeah, it looks like the module-mess in Sinon is getting to be more and more of an issue. I've taken a few attempts at rewriting it for CommonJS, but things are complicated. Pull requests welcome :) |
I've created a ticket for the work of getting the source ported to CommonJS #834, which will most likely obviate this issue. |
I think this issue is solved now in the master with #850 |
Any updates on this? #850 doesn't solve the problem. PS: I'm using v1.17.0 |
@Robertmw you can try pointing sinon to git in your |
@grassator I tried with the below git from webpack/webpack#304 (comment) but I'll try it with the original git right away.
|
@grassator I can confirm that point the dependency on my
solves my problems with Webpack. |
I am also facing the same issue. For now, I am using |
@tusharmath : have you tried using the version hosted on GitHub as mentioned above? Fixes for this is going into version 2, which is yet to be published. This is unlikely to be fixed in the 1.x branch. |
@fatso83 I can confirm that using |
2.0 release should happen soon, so nothing to be sad about |
I've had a project relying on the |
@frank-weindel : The master branch is what is effectively becoming 2.0, so you could just as well point to that. A pre-release of 2.0 should be on NPM in a few days. |
PS. You can get the pre-release of 2.0 by doing npm install sinon@next |
any update on when sinon 2 will be @latest instead of @next? |
Note #966 tracks the outstanding tasks required for shipping Sinon 2.0 which uses CommonJS modules internally - help very much appreciated in getting it out the door. |
try to use it as a webpack plugin ...
plugins: [
new webpack.ProvidePlugin( {
'sinon': 'sinon'
})
],
... |
Just for the record, using it as with |
Personally I just stopped using Karma and thus not needing Webpack for unit tests. The makes them way faster to run also. Does this issue still exist? Other wise we can close it. |
The issue still exists in sinon < 2.0, which is still not officially released. I recommend closing this issue either with a fix or when sinon 2.0 ships. |
This works in Sinon 2.0 and the README has since long had a BIG FAT WARNING that bundlers like WebPack do not work with Sinon 1.x. If you need to bundle, use one of the pre-release versions of Sinon. Closing this. |
When trying to import sinon in a test with "import sinon from 'sinon'" or "var sinon = require('sinon')". I get the following error:
TypeError: 'undefined' is not an object (evaluating 'modules[moduleId].call')
Now sinon is unusable in ES6 projects. Is it possible to fix this?
var sinon = require('sinon');
The text was updated successfully, but these errors were encountered: