Skip to content

Commit

Permalink
chore(testing): stop log4js output in unit tests (#3634)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjbarton authored Jan 27, 2021
1 parent b5c0baa commit 8d589ed
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/unit/mocha-globals.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8d589ed

Please sign in to comment.