1.0.1 • Published 4 years ago

@mayachit/mocha-pretty-bunyan v1.0.1

Weekly downloads
27
License
MIT
Repository
github
Last release
4 years ago

@mayachit/mocha-pretty-bunyan

Description

bunyan is a pretty nice package to log in JSON format, and provides an awesome cli to display it in human readable way. However, when you run your test with mocha, you cannot take benefit of the cli, so you then get raw JSON logs that is a mess to read.

@mayachit/mocha-pretty-bunyan displays the bunyan log stream using a pretty/human readable format in the context of a mocha reporter. @mayachit/mocha-pretty-bunyan does not actually implement a mocha reporter, rather just wraps the stdout stream of a mocha reporter (spec, by default) using @ambassify/bunyan-prettystream.

Install

npm install @mayachit/mocha-pretty-bunyan --save-dev

Note that @mayachit/mocha-pretty-bunyan itself does not depend on a version of mocha or bunyan, but declares them as a peerDependency assuming that you already have both mocha and bunyan installed.

Usage

mocha --reporter @mayachit/mocha-pretty-bunyan

Configuration

@mayachit/mocha-pretty-bunyan will attempt to load a JSON configuration file from test/mocha-pretty-bunyan.json. A custom configuration file can also be specified using the MOCHA_PRETTY_BUNYAN_CONFIG environment variable.

The following configurations are supported:

KeyDefault ValueDescription
mutefalseSet to true if you want to mute all logs
leveltraceValid bunyan log-level
reporterspecMocha reporter to use

Example configuration file:

{
  "mute": false,
  "level": "debug",
  "reporter": "spec"
}

Since @mayachit/mocha-pretty-bunyan essentially require's the mocha reporter specified, any --reporter-options will be passed through to the reporter specified in the configuration above.

For example, if you want to use mocha-multi-reporters, specify mocha-multi-reporters as the reporter in test/mocha-pretty-bunyan.json and then run:

mocha --reporter @mayachit/mocha-pretty-bunyan --reporter-options configFile=test/mocha-multi-reporters.json

Credits