Created
April 29, 2018 19:30
-
-
Save ChrisAlderson/2c6c52939c43b2dee4c7fedeec0f3e01 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const app = require('../app') | |
// [email protected] | |
const LegacyTransport = require('winston-transport/legacy') | |
const request = require('supertest') | |
const sinon = require('sinon') | |
const spyLogger = require('winston-spy') | |
const winston = require('winston') | |
const { expect } = require('chai') | |
describe('app', () => { | |
const spy = sinon.spy() | |
const notFoundLogMessage = '404 not found' | |
let consoleTransport | |
let spyTransport | |
before(() => { | |
// [email protected] | |
// winston.add(winston.transports.Console) | |
// winston.add(spyLogger, { spy }) | |
// [email protected] | |
consoleTransport = new winston.transports.Console({ | |
silent: true | |
}) | |
spyTransport = new LegacyTransport({ | |
transport: new spyLogger({ spy }) | |
}) | |
winston.add(consoleTransport) | |
winston.add(spyTransport) | |
}) | |
it('should log 404 not found message', async () => { | |
await request(app).get('/api') | |
winston.error(notFoundLogMessage) | |
expect(spy.calledWith('error', notFoundLogMessage)).to.equal(true) | |
}) | |
after(() => { | |
// [email protected] | |
// winston.remove(winston.transports.Console) | |
// winston.remove(spyLogger) | |
// [email protected] | |
winston.remove(consoleTransport) | |
winston.remove(spyTransport) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment