Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mocha-tbpl-reporter

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocha-tbpl-reporter - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

examples/duration.js

40

lib/tbpl.js
var Base = require('mocha').reporters.Base;
var fsPath = require('path');

@@ -72,2 +73,3 @@

console.log('TEST-UNEXPECTED-FAIL | %s | %s', file, title);
console.log(err.stack);
this.failing += 1;

@@ -80,4 +82,5 @@ },

onPass: function(test) {
var title = this.getTitle(test);
console.log('TEST-PASS | %s', title);
var title = this.getTitle(test),
file = this.getFile(test);
console.log('TEST-PASS | %s | %s', file, title);
this.passing += 1;

@@ -90,4 +93,5 @@ },

onPending: function(test) {
var title = this.getTitle(test);
console.log('TEST-PENDING | %s', title);
var title = this.getTitle(test),
file = this.getFile(test);
console.log('TEST-PENDING | %s | %s', file, title);
this.pending += 1;

@@ -100,4 +104,5 @@ },

onTest: function(test) {
var title = this.getTitle(test);
console.log('TEST-START | %s', title);
var title = this.getTitle(test),
file = this.getFile(test);
console.log('TEST-START | %s | %s', file, title);
},

@@ -109,4 +114,5 @@

onTestEnd: function(test) {
var title = this.getTitle(test);
console.log('TEST-END | %s', title);
var title = this.getTitle(test),
file = this.getFile(test);
console.log('TEST-END | %s | %s took %d ms', file, title, test.duration);
},

@@ -123,10 +129,22 @@

getFile: function(test) {
var file = null;
if ('file' in test) {
return test.file;
file = test.file;
}
if ('parent' in test) {
return this.getFile(test.parent);
file = this.getFile(test.parent);
}
return null;
// Make the file relative if we have one...
if (file) {
// Resolve ensures we never end up with two trailing slashes...
var pwd = fsPath.resolve(process.cwd()) + '/';
// Make sure the file starts with pwd before replacing it.
if (file.indexOf(pwd) === 0) {
file = file.replace(pwd, '');
}
}
return file;
},

@@ -133,0 +151,0 @@

{
"name": "mocha-tbpl-reporter",
"version": "0.1.3",
"version": "0.2.0",
"author": "The Gaia Team <dev-gaia@lists.mozilla.org>",

@@ -13,3 +13,3 @@ "description": "Mocha reporter for TBPL (tinderboxpushlog)",

"devDependencies": {
"mocha": "1.18.x",
"mocha": "1.21.x",
"sinon": "1.7.3"

@@ -33,4 +33,5 @@ },

"scripts": {
"test": "make"
"test": "make",
"examples": "mocha --reporter $PWD $(find examples)"
}
}

@@ -46,8 +46,12 @@ var TBPL = require('../lib/tbpl'),

var file = 'doge_such_broke_test.js';
subject.onFail({
file: file,
fullTitle: function() {
return 'some title';
}
});
var err = new Error('xfoo');
subject.onFail(
{
file: file,
fullTitle: function() {
return 'some title';
}
},
err
);

@@ -60,2 +64,3 @@ assert.strictEqual(subject.failing, failing + 1);

));
assert.ok(log.calledWith(err.stack));
});

@@ -66,2 +71,3 @@

subject.onPass({
file: 'file.js',
fullTitle: function() {

@@ -73,3 +79,3 @@ return 'some title';

assert.strictEqual(subject.passing, passing + 1);
assert.ok(log.calledWith('TEST-PASS | %s', 'some title'));
assert.ok(log.calledWith('TEST-PASS | %s | %s', 'file.js', 'some title'));
});

@@ -80,2 +86,3 @@

subject.onPending({
file: 'file.js',
fullTitle: function() {

@@ -87,3 +94,5 @@ return 'some title';

assert.strictEqual(subject.pending, pending + 1);
assert.ok(log.calledWith('TEST-PENDING | %s', 'some title'));
assert.ok(
log.calledWith('TEST-PENDING | %s | %s', 'file.js', 'some title')
);
});

@@ -93,2 +102,3 @@

subject.onTest({
file: 'file.js',
fullTitle: function() {

@@ -99,3 +109,3 @@ return 'some title';

assert.ok(log.calledWith('TEST-START | %s', 'some title'));
assert.ok(log.calledWith('TEST-START | %s | %s', 'file.js', 'some title'));
});

@@ -105,2 +115,4 @@

subject.onTestEnd({
duration: 100,
file: 'file.js',
fullTitle: function() {

@@ -111,5 +123,30 @@ return 'some title';

assert.ok(log.calledWith('TEST-END | %s', 'some title'));
assert.ok(
log.calledWith(
'TEST-END | %s | %s took %d ms', 'file.js', 'some title', 100
)
);
});
test('#getFile - relative', function() {
var file = subject.getFile({
file: __dirname + '/xfoo'
});
assert.equal(file, 'test/xfoo');
});
test('#getFile - relative different pwd', function() {
var file = subject.getFile({
file: 'woot/bar.js'
});
assert.equal(file, 'woot/bar.js');
});
test('#getFile - absolute', function() {
var file = subject.getFile({
file: '/magic/foo/bar/file.js'
});
assert.equal(file, '/magic/foo/bar/file.js');
});
test('#getTitle', function() {

@@ -116,0 +153,0 @@ var result = subject.getTitle({

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