How to run tests with sinon?
See original GitHub issueHi, 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?
Issue Analytics
- State:
- Created 9 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Sinon JS Tutorial: A Beginner's Guide To Mocking - Testim Blog
SinonJS is a JavaScript library that provides standalone test spies, stubs, and mocks. It's very flexible and easy to use since you can...
Read more >Sinon.JS - Standalone test fakes, spies, stubs and mocks for ...
Standalone test spies, stubs and mocks for JavaScript. Works with any unit testing framework. · Get Started · Try It Out.
Read more >Best Practices for Spies, Stubs and Mocks in Sinon.js
When you use spies, stubs or mocks, wrap your test function in sinon.test . This allows you to use Sinon's automatic clean-up functionality....
Read more >Sinon Tutorial: JavaScript Testing with Mocks, Spies & Stubs
Put simply, Sinon allows you to replace the difficult parts of your tests with something that makes testing simple. When testing a piece...
Read more >How to Write Unit Tests Using Sinon.js - YouTube
comIn this Sinon.js Tutorial, we give an overview of the Sinon.js l... ... Your browser can't play this video. Learn more. Switch camera....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.noParseThanks @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