Sinon stub throwing Attempted to wrap object which is already wrapped
<p>Although there are posts regarding this , I could not fix it using before, after functions and restoring the objects. Posting the code below:-</p>

<pre><code>var Log = sinon.stub(hello, 'someEvent', function(type, name){
        var obj = {};
        obj.addData = function(data){
            return;
        };
        obj.complete = function(){
            return;
        }
        return obj;
     }),
    someVar = sinon.stub(servicecore, 'some'),
</code></pre>

<p>The error I get is:- </p>

<pre><code>Attempted to wrap someEvent which is already wrapped.
</code></pre>

<p>And</p>

<pre><code>Attempted to wrap some which is already wrapped.
</code></pre>

<p>Can someone help with this?</p>

<blockquote>
  <p>Edited below</p>
</blockquote>

<p>I even tried with before and after functions as suggested:-</p>

<pre><code>var Log,someVar;

before(function(){

   Log = sinon.stub(hello, 'someEvent', function(type, name){
            var obj = {};
            obj.addData = function(data){
                return;
            };
            obj.complete = function(){
                return;
            }
            return obj;
         });
    someVar = sinon.stub(servicecore, 'some');

});

after(function(){

    Log.restore();
    someVar.restore();
});
</code></pre>

<p>Tried even with beforeEach and afterEach functions but same error. </p>