Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(log4jsMock): Restore sandbox in log4js mock #122

Merged
merged 1 commit into from
Jul 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;