Skip to content
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

How to run tests with sinon? #43

Closed
marr opened this issue Mar 12, 2015 · 7 comments
Closed

How to run tests with sinon? #43

marr opened this issue Mar 12, 2015 · 7 comments

Comments

@marr
Copy link

marr commented Mar 12, 2015

Hi,
I am trying to run a test package and noticing that webpack still seems to bundle things in node_modules even though I am using the following karma/webpack config: https://gist.github.com/fb66622fa8284c76e6d9

An example test file:

'use strict';

var React = require('react/addons');
//var sinon = require('sinon');

React gets bundled, without issue even though I'd think that excludes would ignore it.
The issue is when I uncomment the sinon test, I get several critical issues:

WARNING in ./~/sinon/lib/sinon.js
Critical dependencies:
39:25-32 require function is used in a way, in which dependencies cannot be statically extracted
 @ ./~/sinon/lib/sinon.js 39:25-32

WARNING in ./~/sinon/lib/sinon/behavior.js
Critical dependencies:
353:25-32 require function is used in a way, in which dependencies cannot be statically extracted
 @ ./~/sinon/lib/sinon/behavior.js 353:25-32

Am I just doing things wrong by expecting mocha tests to run like they would on the server?

@ColCh
Copy link

ColCh commented Mar 12, 2015

Just use sinon framework for karma - sinon's API will be global within tests

@marr
Copy link
Author

marr commented Mar 14, 2015

Thanks @ColCh I ended up doing that and its working great. Here's an example if anyone wants to see it. https://github.com/bitwise/status

@marr marr closed this as completed Mar 14, 2015
@josmardias
Copy link

@marr your link is broken

@marr
Copy link
Author

marr commented Feb 17, 2016

@josmardias I will look at pushing it back up somewhere. Meantime, you should be able to use https://github.com/kmees/karma-sinon-chai

@ColCh
Copy link

ColCh commented Feb 17, 2016

@josmardias use karma-sinon or karma-sinon-chai

If you need your unique setup, you can simple require sinon within webpack, and use modules: noparse: [ /sinon\.js/ ] within your webpack config (that worked for me). Documentation for module.noParse

@josmardias
Copy link

I'll try it, thanks!

@tschaub
Copy link
Contributor

tschaub commented Feb 12, 2017

Came across this same issue and found that it is fixed in sinon@2.0.0-pre.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants