Skip to content

Instantly share code, notes, and snippets.

@fatso83
Created March 7, 2019 09:11
Show Gist options
  • Save fatso83/ed08e222ab23d3f96445cf7b0c77ac5f to your computer and use it in GitHub Desktop.
Save fatso83/ed08e222ab23d3f96445cf7b0c77ac5f to your computer and use it in GitHub Desktop.
Example of using mini-mocha for demos
// Runnable example of a supposed issue with `sinon-test`
// Employs 'mini-mocha' to emulate running in the Mocha test runner (mochajs.org)
// @author Carl-Erik Kopseng
require("@fatso83/mini-mocha")
const sinon = require("sinon");
const sinonTest = require("sinon-test");
const test = sinonTest(sinon);
describe("issue #101 ES2015 version", function() {
class MyClass {
static myMethod() {
return "originalReturn";
}
}
it("test 1", test(function() {
sinon.stub(MyClass, "myMethod");
}));
it("test 2", test(function() {
sinon.stub(MyClass, "myMethod");
}));
});
describe("issue #101 ES5 version", function() {
var Foo = {
myMethod: function() { return "original"; }
}
it("test 1", test(function() {
sinon.stub(Foo, "myMethod");
}));
it("test 2", test(function() {
sinon.stub(Foo, "myMethod");
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment