Socket
Socket
Sign inDemoInstall

tap-mocha-reporter

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tap-mocha-reporter - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

both.out

21

lib/reporters/dump.js
exports = module.exports = Dump
var Base = require('./base')
, cursor = Base.cursor
, color = Base.color;
, color = Base.color
, useColors = Base.useColors
, util = require('util')

@@ -12,3 +14,2 @@ function Dump(runner) {

'version',
'end',
'suite',

@@ -30,8 +31,12 @@ 'suite end',

runner.on('line', function (c) {
if (c.trim())
process.stderr.write(Base.color('bright yellow', c))
})
events.forEach(function (ev) {
runner.on(ev, function () {
runner.on(ev, function (obj) {
console.log(ev)
if (arguments.length) {
var args = [].concat.apply([], arguments)
console.log.apply(console, args)
console.log(util.inspect(obj, false, Infinity, useColors))
console.log()

@@ -41,2 +46,8 @@ }

})
runner.on('end', function () {
console.log('end')
console.log(runner.stats)
console.log()
})
}

@@ -49,4 +49,6 @@ // A facade from the tap-parser to the Mocha "Runner" object.

var Parser = require('tap-parser')
var timere = /^#\s*time=((?:0|[1-9][0-9]*)(:?\.[0-9]+)?)(ms|s)?\n$/
// $1 = number, $2 = units
var timere = /^#\s*time=((?:0|[1-9][0-9]*?)(?:\.[0-9]+)?)(ms|s)?$/
util.inherits(Runner, Writable)

@@ -82,3 +84,3 @@

else
return this.parent.fullTitle() + ' ' + (this.name || '').trim()
return (this.parent.fullTitle() + ' ' + (this.name || '')).trim()
}

@@ -90,2 +92,5 @@

if (level === 0) {
parser.on('line', function (c) {
runner.emit('line', c)
})
parser.on('version', function (v) {

@@ -95,4 +100,14 @@ runner.emit('version', v)

parser.on('complete', function (res) {
runner.emit('end', runner.stats)
runner.emit('end')
})
parser.on('comment', function (c) {
var tmatch = c.trim().match(timere)
if (tmatch) {
var t = +tmatch[1]
if (tmatch[2] === 's')
t *= 1000
parser.time = t
runner.stats.duration = t
}
})
}

@@ -102,2 +117,3 @@

parser.didAssert = false
parser.printed = false
parser.name = ''

@@ -131,2 +147,3 @@ parser.doingChild = null

parser.on('child', function (child) {
//console.log('>>> child')
child.parent = parser

@@ -146,19 +163,6 @@ attachEvents(runner, child, level + 1)

parser.on('comment', function (c) {
if (c.match(/^# Subtest: /)) {
if (!this.printed && c.match(/^# Subtest: /)) {
c = c.trim().replace(/^# Subtest: /, '')
parser.name = c
this.name = c
}
// get the top-level duration from the trailing comment,
// if one occurs.
if (!this.suite || this.suite.root) {
var m = c.match(timere)
if (m) {
var time = m[1]
if (m[2] === 's')
time *= 1000
runner.stats.duration = Math.round(time, 0)
}
}
})

@@ -172,15 +176,18 @@

parser.on('assert', function (result) {
emitSuite(this, result)
emitSuite(this)
// no need to print the trailing assert for subtests
// just do a 'suite end' event for this.
if (this.doingChild && this.doingChild.didAssert &&
this.doingChild.name === result.name) {
// we've already emitted a 'suite end' event for this.
if (this.doingChild) {
var suite = this.doingChild.suite
if (this.doingChild.didAssert &&
this.doingChild.name === result.name) {
if (suite && result.time)
suite.duration = result.time
}
this.doingChild = null
if (suite) {
suite.duration = Math.round(result.time, 0)
runner.emit('suite end', this.doingChild.suite)
runner.emit('suite end', suite)
return
}
this.doingChild = null
return
}

@@ -219,9 +226,11 @@

function emitSuite (parser, result) {
if (!parser.emittedSuite && (parser.name || parser.level === 0)) {
function emitSuite (parser) {
//console.log('emitSuite', parser.emittedSuite, parser.level, parser.name)
if (!parser.emittedSuite && parser.name) {
parser.emittedSuite = true
var suite = parser.suite = new Suite(parser)
if (parser.parent && parser.parent.suite) {
if (parser.parent && parser.parent.suite)
parser.parent.suite.suites.push(suite)
}
if (parser.runner.stats)
parser.runner.stats.suites ++

@@ -236,7 +245,2 @@ parser.runner.emit('suite', suite)

if (!parser.suite) {
emitSuite(parser, result)
}
if (parser.suite) {

@@ -246,4 +250,2 @@ //if (test.parent === parser)

parser.suite.tests.push(test)
} else {
console.error('test without suite?')
}

@@ -250,0 +252,0 @@

@@ -18,5 +18,5 @@ // minimal mock of mocha's Suite class for formatters

if (!this.parent)
return this.title || ''
return (this.title || '').trim()
else
return this.parent.fullTitle() + ' ' + (this.title || '').trim()
return (this.parent.fullTitle() + ' ' + (this.title || '')).trim()
}
{
"name": "tap-mocha-reporter",
"version": "0.0.5",
"version": "0.0.6",
"description": "Format a TAP stream using Mocha's set of reporters",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc