From 8d589ed9a94e9e8becab9de853fbefce3fdf4807 Mon Sep 17 00:00:00 2001 From: johnjbarton Date: Wed, 27 Jan 2021 10:58:49 -0800 Subject: [PATCH] chore(testing): stop log4js output in unit tests (#3634) Use https://log4js-node.github.io/log4js-node/recording.html to verify logs --- test/unit/mocha-globals.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/unit/mocha-globals.js b/test/unit/mocha-globals.js index 8afdd587b..6659714ee 100644 --- a/test/unit/mocha-globals.js +++ b/test/unit/mocha-globals.js @@ -1,6 +1,7 @@ const sinon = require('sinon') const chai = require('chai') const logger = require('../../lib/logger') +const recording = require('log4js/lib/appenders/recording') // publish globals that all specs can use global.expect = chai.expect @@ -15,13 +16,14 @@ chai.use(require('chai-subset')) beforeEach(() => { global.sinon = sinon.createSandbox() - // set logger to log INFO, but do not append to console - // so that we can assert logs by logger.on('info', ...) - logger.setup('INFO', false, []) + // Use https://log4js-node.github.io/log4js-node/recording.html to verify logs + const vcr = { vcr: { type: 'recording' } } + logger.setup('INFO', false, vcr) }) afterEach(() => { global.sinon.restore() + recording.erase() }) // TODO(vojta): move to helpers or something