Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing File transport in mocha does not work #14

Open
basickarl opened this issue Dec 9, 2016 · 0 comments
Open

Testing File transport in mocha does not work #14

basickarl opened this issue Dec 9, 2016 · 0 comments

Comments

@basickarl
Copy link

basickarl commented Dec 9, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant