Skip to content
This repository has been archived by the owner on Sep 7, 2018. It is now read-only.

sinon.js stubs are reset, before tearDown #424

Open
dkl-ppi opened this issue Oct 1, 2014 · 0 comments
Open

sinon.js stubs are reset, before tearDown #424

dkl-ppi opened this issue Oct 1, 2014 · 0 comments
Assignees
Milestone

Comments

@dkl-ppi
Copy link
Member

dkl-ppi commented Oct 1, 2014

Executing this test (stub-test.js):

"use strict";

var buster = require("buster"),
    assert = buster.assert,
    refute = buster.refute;

buster.testCase("stub reset test", {

    setUp: function () {
        this.server = {
            close: function () {
                throw new Error("server is not running");
            }
        };
        this.stub(this.server, "close");
        refute.exception(this.server.close);
    },

    tearDown: function () {
        refute.exception(this.server.close);
    },

    "method close should be stubbed": function () {
        refute.exception(this.server.close);
    }
});

leads to the following result:

Failure: stub reset test method close should be stubbed
  [refute.exception] Expected not to throw but threw Error (server is not running)
    AssertionError: [refute.exception] Expected not to throw but threw Error (server is not running)
          at Object.referee.fail (D:\busterDev\referee\lib\referee.js:156:25)
          at Object.fail (D:\busterDev\referee\lib\referee.js:43:17)
          at Function.refute.exception (D:\busterDev\referee\lib\referee.js:562:18)
          at Object.buster.testCase.tearDown (D:\busterDev\buster-ci\test\stub-test.js:20:16)
          at asyncFunction (D:\busterDev\buster-test\lib\test-runner.js:224:19)
          at callAndWait (D:\busterDev\buster-test\lib\test-runner.js:253:23)
          at next (D:\busterDev\buster-test\lib\test-runner.js:273:31)
          at callSerially (D:\busterDev\buster-test\lib\test-runner.js:279:9)
          at Object.bane.createEventEmitter.callTearDowns (D:\busterDev\buster-test\lib\test-runner.js:589:20)
          at Object.<anonymous> (D:\busterDev\buster-test\lib\test-runner.js:626:17)
1 test, 2 assertions, 1 runtime ... 1 failure

As you can see, the failure occurs in line 20 of the test, which is inside of tearDown.
Question is, what is more useful, to reset the stubs before or after tearDown?

@dkl-ppi dkl-ppi added this to the 1.x milestone Jul 14, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants