Skip to content

Commit

Permalink
fix(log4jsMock): Restore sandbox in log4js mock (#122)
Browse files Browse the repository at this point in the history
For the log4js mock, it is nessesery to restore it after each test run in order to clean in for the next one (if there is a next one)
  • Loading branch information
nicojs authored and simondel committed Jul 12, 2016
1 parent 60191e3 commit e3f3ce1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/helpers/log4jsMock.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
console.log('l4js:', require.resolve('log4js'));
import * as log4js from 'log4js';
import * as sinon from 'sinon';

const l = log4js.getLogger();
let logger = {
isTraceEnabled: sinon.stub(),
trace: sinon.stub(),
Expand All @@ -16,8 +16,10 @@ let logger = {
isFatalEnabled: sinon.stub(),
fatal: sinon.stub()
};
let sandbox = sinon.sandbox.create();

sinon.stub(log4js, 'getLogger').returns(logger);
// Stub away even before other files are loaded and tests have started
sandbox.stub(log4js, 'getLogger').returns(logger);

beforeEach(() => {
logger.trace.reset();
Expand All @@ -28,4 +30,9 @@ beforeEach(() => {
logger.fatal.reset();
});

after( () => {
// Restore for next (stryker) test run
sandbox.restore();
});

export default logger;

0 comments on commit e3f3ce1

Please sign in to comment.