Skip to content

Testing File transport in mocha does not work #14

@basickarl

Description

@basickarl

I've looked at your tests for bragi and they do not cover everything. So I tried to cover for example if a log file is actually made when a File transport is added. I checked to see if it worked and apparently it does not. Check below:

test/log.js

'use strict';

import fs from 'fs';
import logger from 'bragi';

// Logging to file.
logger.transports.add(new logger.transportClasses.File({
  filename: 'test.log'
}));

describe('Log', () => {
  it('logger creates a log file when a log is logged', () => {
    logger.log('error', 'test log');
  });
});

test/mocha.opts:

--recursive
--compilers js:babel-core/register
--require babel-polyfill

run via npm test, in the package.json:

"test": "NODE_ENV=test NODE_PATH=\"$(pwd)\" mocha",

As you can see, it outputs via the Console transport:

  Log
[ ✘   error  ] 	test log
  2016-12-09T10:58:26.283Z	 /home/karlm/dev/node/proj/test/log.js:20:21
    ✓ logger creates a log file when a log is logged


  1 passing (26ms)

It however does not create the file test.log.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions