Skip to content

Commit 76399ab

Browse files
committed
Silence logger in tests
At the moment, the logger will log to console during tests, which is noisy and undesirable. This change adds a test setup file, which silences the logger by setting all of its methods to no-ops. This behaviour can be overridden with the `LOGGING` environment variable: ```bash LOGGING=true npm test ```
1 parent 9e1e166 commit 76399ab

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

test/mocha.opts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
--reporter spec
22
--check-leaks
33
--recursive
4+
--file test/setup.js

test/setup.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var logger = require('../lib/logger');
2+
3+
if (process.env.LOGGING !== 'true') {
4+
// Silence the logger for tests by setting all its methods to no-ops
5+
logger.setMethods({
6+
info: function() {},
7+
warn: function() {},
8+
error: function() {}
9+
});
10+
}

0 commit comments

Comments
 (0)