karma-spec-reporter
Advanced tools
Comparing version 0.0.34 to 0.0.35
50
index.js
@@ -1,2 +0,3 @@ | ||
var colors = require('colors'); | ||
var colors = require('colors'), | ||
LOG_PRIORITIES = require('karma').constants.LOG_PRIORITIES; | ||
@@ -18,5 +19,15 @@ var SpecReporter = function (baseReporterDecorator, formatError, config) { | ||
this.failures = []; | ||
this.USE_COLORS = false; | ||
this.slowPokes = []; | ||
this.USE_COLORS = false; | ||
this.SPEC_FAILURE = '%s %s FAILED\n'; | ||
this.SPEC_SLOW = '%s SLOW %s: %s\n'; | ||
this.ERROR = '%s ERROR\n'; | ||
this.FINISHED_ERROR = ' ERROR'; | ||
this.FINISHED_SUCCESS = ' SUCCESS'; | ||
this.FINISHED_DISCONNECTED = ' DISCONNECTED'; | ||
this.X_FAILED = ' (%d FAILED)'; | ||
this.TOTAL_SUCCESS = 'TOTAL: %d SUCCESS\n'; | ||
this.TOTAL_FAILED = 'TOTAL: %d FAILED, %d SUCCESS\n'; | ||
// colorize output of BaseReporter functions | ||
@@ -45,9 +56,12 @@ if (config.colors) { | ||
if (browsers.length >= 1 && !results.disconnected && !results.error) { | ||
var currentTime = reporterCfg.showSpecTiming ? | ||
(this.USE_COLORS ? (new Date().toLocaleString() + ' - ').yellow : (new Date().toLocaleString() + ' - ')) : | ||
''; | ||
if (!results.failed) { | ||
if (!this.suppressSummary) { | ||
this.write(this.TOTAL_SUCCESS, results.success); | ||
this.write(currentTime + this.TOTAL_SUCCESS, results.success); | ||
} | ||
} else { | ||
if (!this.suppressSummary) { | ||
this.write(this.TOTAL_FAILED, results.failed, results.success); | ||
this.write(currentTime + this.TOTAL_FAILED, results.failed, results.success); | ||
} | ||
@@ -80,4 +94,9 @@ if (!this.suppressErrorSummary) { | ||
this.writeCommonMsg((index + ') ' + failure.description + '\n').red); | ||
this.writeCommonMsg((this.WHITESPACE + failure.suite.join(' ') + '\n').red); | ||
this.writeCommonMsg(this.USE_COLORS ? | ||
(index + ') ' + failure.description + '\n').red : | ||
(index + ') ' + failure.description + '\n')); | ||
this.writeCommonMsg(this.USE_COLORS ? | ||
(this.WHITESPACE + failure.suite.join(' ') + '\n').red : | ||
(this.WHITESPACE + failure.suite.join(' ') + '\n')); | ||
failure.log.forEach(function (log) { | ||
@@ -87,4 +106,5 @@ if (reporterCfg.maxLogLines) { | ||
} | ||
this.writeCommonMsg(this.WHITESPACE + formatError(log) | ||
.replace(/\\n/g, '\n').grey); | ||
this.writeCommonMsg(this.USE_COLORS ? | ||
(this.WHITESPACE + formatError(log).replace(/\\n/g, '\n')).grey : | ||
(this.WHITESPACE + formatError(log).replace(/\\n/g, '\n'))); | ||
}, this); | ||
@@ -149,3 +169,3 @@ }, this); | ||
if (this.reportSlowerThan && result.time > config.reportSlowerThan) { | ||
if (config.reportSlowerThan && result.time > config.reportSlowerThan) { | ||
this.logSlowPoke(result); | ||
@@ -178,8 +198,12 @@ } | ||
this.LOG_MULTI_BROWSER = '%s %s LOG: %s\n'; | ||
var bCfg = config && config.browserConsoleLogOptions || {}; | ||
var bLogThreshold = LOG_PRIORITIES.indexOf((bCfg && bCfg.level || 'DEBUG').toUpperCase()); | ||
var doLog = config && config.browserConsoleLogOptions && config.browserConsoleLogOptions.terminal; | ||
this.onBrowserLog = doLog ? function (browser, log, type) { | ||
this.onBrowserLog = bCfg.terminal ? function (browser, log, type) { | ||
type = type.toUpperCase(); | ||
if (LOG_PRIORITIES.indexOf(type) > bLogThreshold) return; | ||
if (this._browsers && this._browsers.length === 1) { | ||
this.write(this.LOG_SINGLE_BROWSER, type.toUpperCase(), this.USE_COLORS ? log.cyan : log); | ||
this.write(this.LOG_SINGLE_BROWSER, type, this.USE_COLORS ? log.cyan : log); | ||
} else { | ||
this.write(this.LOG_MULTI_BROWSER, browser, type.toUpperCase(), this.USE_COLORS ? log.cyan : log); | ||
this.write(this.LOG_MULTI_BROWSER, browser, type, this.USE_COLORS ? log.cyan : log); | ||
} | ||
@@ -214,3 +238,3 @@ } : noop; | ||
this.showBrowser = reporterCfg.showBrowser || false; | ||
this.reportSlowerThan = config.reportSlowerThan || false; | ||
this.reportSlowerThan = config.reportSlowerThan || reporterCfg.reportSlowerThan || false; | ||
}; | ||
@@ -217,0 +241,0 @@ |
{ | ||
"name": "karma-spec-reporter", | ||
"version": "0.0.34", | ||
"version": "0.0.35", | ||
"description": "A Karma plugin. Report all spec-results to console (like mocha's spec reporter).", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha-runner --reporter spec test/**/*.spec.js", | ||
"coverage": "istanbul cover -x test/**/*.js node_modules/mocha/bin/_mocha -- --reporter spec test/**/*.js", | ||
"precoverage-report": "run-s coverage", | ||
"coverage-report": "istanbul report" | ||
"test": "nyc --reporter=html --reporter=text mocha", | ||
"coverage": "npm run test && nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
@@ -22,3 +20,3 @@ "repository": { | ||
"dependencies": { | ||
"colors": "1.4.0" | ||
"colors": "^1.4.0" | ||
}, | ||
@@ -30,10 +28,9 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"chai": "^3.4.0", | ||
"coveralls": "^2.11.4", | ||
"istanbul": "^0.4.0", | ||
"mocha": "^3.2.0", | ||
"mocha-runner": "^1.1.1", | ||
"chai": "^4.3.7", | ||
"coveralls": "^3.1.1", | ||
"mocha": "^10.1.0", | ||
"npm-run-all": "^4.0.2", | ||
"sinon": "^1.17.2", | ||
"sinon-chai": "^2.8.0" | ||
"nyc": "^15.1.0", | ||
"sinon": "^14.0.2", | ||
"sinon-chai": "^3.7.0" | ||
}, | ||
@@ -40,0 +37,0 @@ "files": [ |
# karma-spec-reporter | ||
[![Join the chat at https://gitter.im/mlex/karma-spec-reporter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mlex/karma-spec-reporter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/mlex/karma-spec-reporter.svg)](https://travis-ci.org/mlex/karma-spec-reporter) | ||
[![Coverage Status](https://coveralls.io/repos/mlex/karma-spec-reporter/badge.svg?branch=master&service=github)](https://coveralls.io/github/mlex/karma-spec-reporter?branch=master) | ||
[![Join the chat at https://gitter.im/mlex/karma-spec-reporter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mlex/karma-spec-reporter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![CircleCI](https://circleci.com/gh/tmcgee123/karma-spec-reporter/tree/master.svg?style=svg)](https://circleci.com/gh/tmcgee123/karma-spec-reporter/tree/master) | ||
[![Coverage Status](https://coveralls.io/repos/github/tmcgee123/karma-spec-reporter/badge.svg?branch=master)](https://coveralls.io/github/tmcgee123/karma-spec-reporter?branch=master) | ||
@@ -6,0 +6,0 @@ Test reporter, that prints detailed results to console (similar to mocha's spec reporter). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14203
7
204
Updatedcolors@^1.4.0