tran2 / karma-json-log-reporter

A simple Karma reporter for logging json messages from matchers and specs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

karma-json-log-reporter

NPM version Build status

A simple Karma reporter for logging json messages from matchers and specs.

Installation

Install from NPM:

npm install karma-json-log-reporter

Usage

Required Karma configuration includes typical wire-up via Karma plug-ins and reporters, and optionally specifying the destination path for JSON output:

{
	"jsonLogReporter": {
		"outputPath": "test/some/path/"
	},
	"plugins": [
		"karma-json-log-reporter"
	],
	"reporters": ["json-log"]
}

JSON logged via console.log and window.dump is sent to the default JSON file 'logFile_timestamp.json'.

window.dump( JSON.stringify( obj ) );

console.log( JSON.stringify( obj ) );

Alternatively, if an object is provided with a name and object, the object is logged to a file according to the specified name, ex. 'myObjectName.json'.

var obj = {
	'name': 'myObjectName',
	'object': objectToLog
};

window.dump( JSON.stringify( obj ) );

Note: if the target file exists with an object, the new object is merged with the existing object and the existing file is updated.

To overwrite, add to Karma configuration:

{
	"jsonLogReporter": {
		"overwrite": true
	}
}

About

A simple Karma reporter for logging json messages from matchers and specs.

License:Apache License 2.0


Languages

Language:JavaScript 100.0%