elliotf / mocha-sinon Goto Github PK
View Code? Open in Web Editor NEWIntegration between sinon and mocha, allowing for automatic cleanup of spies
License: MIT License
Integration between sinon and mocha, allowing for automatic cleanup of spies
License: MIT License
You recommend to use code like
var sinon = require('sinon');
beforeEach(function() {
this.sinon = sinon.sandbox.create();
});
afterEach(function(){
this.sinon.restore();
});
and something similar is happening inside module itself. What are the pros of such solution comparing to
var sinon = require('sinon').sandbox.create();
afterEach(function(){
sinon.restore();
});
?
Is there any particular reason that sinon
remains as a dev-dependency as opposed to just a plain dependency? It just seems kind of redundant to have to type npm i -D sinon mocha-sinon
instead of just installing mocha-sinon
and letting it install sinon
automatically.
sinon v2.0.0 has been released but is not yet compatible with mocha-sinon.
It would be great if someone could update this package. :)
I'm trying to use mocha-sinon in the browser with browserify where sinon isn't attached to window.
if (
typeof window === "object"
&& typeof window.sinon === "object"
) {
plugin(window.sinon);
} else if (typeof require === "function" && typeof window === 'undefined') {
var sinon = require('sinon');
module.exports = function () {
plugin(sinon);
};
plugin(sinon);
} else {
throw "This module loading schema is unsupported. Pull requests are welcome!";
}
The else if
above works perfectly if the check for && typeof window === 'undefined'
is removed. Is there a particular reason it needs to be there?
peerDependencies is causing this to fail when installing
npm ERR! peerinvalid The package mocha does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants mocha@~1
...because the module is only loaded by require()
on the first test run. Suggest you make the module module.exports = function()
and then the usage would be require('mocha-sinon')()
.
I want to return a mock when my code calls "/test" GET endpoint. Is there any way?
Hi!
Thanks for the lib! Unfortunately cant get it work with mocha 3.4.2
node_modules/mocha-sinon/mocha-sinon.js:5
throw "mocha-sinon relies on mocha having been loaded.";
^
mocha-sinon relies on mocha having been loaded.
It seems like mocha does not expose beforeEach
for modules required using cli args:
mocha -r mocha-sinon -r should -r should-sinon --recursive tests
Is there some solution for this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.