Sinon issue reproducible bug template

node v12.22.12
version: 4.0.0
endpointsharetweet
// Employs 'mini-mocha' to emulate running in the Mocha test runner (mochajs.org) require("@fatso83/mini-mocha").install(); const sinon = require("sinon"); const {assert} = require('@sinonjs/referee'); describe("stubbing", function() { class MyClass { static myClassMethod() { return "myClassMethod"; } myMethod() { return "myMethod"; } } afterEach(function() { sinon.restore(); }); it("should set the return value", function() { sinon.replace(MyClass, "myClassMethod", sinon.fake.returns("something else")); assert.equals( MyClass.myClassMethod(), "something else"); }); it("should stub the methods", function() { const obj = {foo(){ return 42; }}; sinon.stub(obj); assert.equals(typeof obj.foo.callCount, "number"); }); }); describe("another issue", function() { it("test 1", function() { throw new Error("whoops"); }); it("supports sync callbacks", function(done) { done(); }); it("supports async callbacks", function(done) { setTimeout(function(){ assert.equals(1,1); done(); }, 100); }); it("also supports Promise resolution", function() { return new Promise(function(resolve, reject) { setTimeout(resolve, 100); }); }); it("also supports async/await", async function() { function doSomethingSlow(){ return new Promise(function(resolve, reject) { setTimeout(resolve.bind(null, 4), 100); }); }; const result = await doSomethingSlow(); assert.equals(result, 4); }); });
Loading…

no comments

    sign in to comment