Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Store _enhanced early enough

This way, enhance() can be called multiple times, which is useful
when it's done on top of module level.
Otherwise, wrapped method will call itself infinitely.
  • Loading branch information...
commit 7b4dcd47ddb9fbe860591d8918a4bb4302ed195f 1 parent d23f87b
@Almad Almad authored
Showing with 6 additions and 5 deletions.
  1. +1 −2  lib/mocha-hooks.js
  2. +5 −3 lib/sinon-mocha.js
View
3  lib/mocha-hooks.js
@@ -40,11 +40,10 @@ MochaHooks = {
beforeEachHook.ctx = suite.ctx;
beforeEachHook.timeout(suite.timeout());
suite._beforeEach.unshift(beforeEachHook);
-
- MochaHooks._enhanced = true;
}
return runSuite.apply(this, arguments);
};
+ MochaHooks._enhanced = true;
},
/**
View
8 lib/sinon-mocha.js
@@ -10,9 +10,11 @@ SinonMocha = {
enhance: function(sinon, mocha){
SinonMocha.sinon = sinon;
- Hooks.enhance(mocha);
- Hooks.beforeEach(SinonMocha.beforeEach);
- Hooks.afterEach(SinonMocha.afterEach);
+ if (!Hooks._enhanced) {
+ Hooks.enhance(mocha);
+ Hooks.beforeEach(SinonMocha.beforeEach);
+ Hooks.afterEach(SinonMocha.afterEach);
+ }
},
beforeEach: function(){
Please sign in to comment.
Something went wrong with that request. Please try again.