Created
March 7, 2019 09:11
-
-
Save fatso83/ed08e222ab23d3f96445cf7b0c77ac5f to your computer and use it in GitHub Desktop.
Example of using mini-mocha for demos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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