Comparing version 0.7.0 to 0.8.0
@@ -188,4 +188,3 @@ /* | ||
suite.addTest(test); | ||
} | ||
else if (!dataset) { | ||
} else if (!dataset) { | ||
// Scenario w/o variants | ||
@@ -280,12 +279,13 @@ _createVariant(LABELS.variant + ': ' + title, null, fn); | ||
if (options.manual) { | ||
fn = null; // Pending test, won't be executed | ||
var _fn = fn; | ||
if (options.manual || suites[0].pending) { | ||
_fn = null; // Pending test, won't be executed | ||
} | ||
if (!options.async && fn instanceof Function && !fn.length) { | ||
if (!options.async && _fn instanceof Function && !_fn.length) { | ||
// Only when the step has not been called with the .async modifier, | ||
// and fn is a Function, and such a function does not have any arguments | ||
fn = sync.asyncIt(fn); | ||
_fn = sync.asyncIt(_fn); | ||
} | ||
var test = new Test(LABELS[options.type] + ': ' + title, fn); | ||
var test = new Test(LABELS[options.type] + ': ' + title, _fn); | ||
test.file = file; | ||
@@ -535,3 +535,5 @@ suites[0].addTest(test); | ||
if (!global.protractor) { | ||
throw new Error('promisize can only be used when running Protractor'); | ||
// If Tartare is run out of Protractor, this function does nothing instead of throwing an error. | ||
// This is useful to run Tartare with the gherkin-md reporter without running Protractor. | ||
return; | ||
} | ||
@@ -583,3 +585,15 @@ | ||
/** | ||
* Wait some time before calling the cb function. It works like the native node.js setTimeout function | ||
* but the cb is the last argument, which allows this function to be "synchronized" | ||
* to be used in synchronous steps. | ||
* | ||
* @param delay | ||
* @param cb | ||
*/ | ||
context.sleep = sync(function sleep(delay, cb) { | ||
setTimeout(cb, delay); | ||
}); | ||
}); | ||
}; |
@@ -91,2 +91,6 @@ /* | ||
runner.on('start', function() { | ||
self.start = new Date(); | ||
}); | ||
runner.on('suite', function(suite) { | ||
@@ -97,2 +101,3 @@ if (!suite.type) { | ||
suite.start = new Date(); | ||
suite.manual = suite.manual || suite.hasManualChildren; | ||
@@ -144,2 +149,3 @@ runner.emit(suite.type, suite); | ||
suite.duration = new Date() - suite.start; | ||
runner.emit(suite.type + ' end', suite); | ||
@@ -178,4 +184,3 @@ }); | ||
runner.emit('step fail', test, err); | ||
} | ||
else if (isHook(test)) { | ||
} else if (isHook(test)) { | ||
runner.emit('hook fail', test, err); | ||
@@ -187,2 +192,3 @@ } | ||
mergeFeatureStats(self.stats); | ||
self.duration = new Date() - self.start; | ||
}); | ||
@@ -189,0 +195,0 @@ } |
@@ -381,4 +381,4 @@ /* | ||
/* eslint-disable no-process-exit */ | ||
process.exit(0); | ||
// Remove the whole suite so the Mocha runner does not execute any test, and finish. | ||
runner.suite.suites = []; | ||
}); | ||
@@ -385,0 +385,0 @@ |
@@ -122,3 +122,3 @@ /* | ||
function pad(str, len, paddingStr) { | ||
var padding = new Array(len).join(paddingStr || ' '); | ||
var padding = new Array(len + 1).join(paddingStr || ' '); | ||
return String(padding + str).slice(-padding.length); | ||
@@ -129,6 +129,12 @@ } | ||
if (obj === null) { | ||
return style.italic('null'); | ||
if (style.italic) { | ||
return style.italic('null'); | ||
} | ||
return 'null'; | ||
} | ||
if (obj === undefined) { | ||
return style.italic('undefined'); | ||
if (style.italic) { | ||
return style.italic('undefined'); | ||
} | ||
return 'undefined'; | ||
} | ||
@@ -202,4 +208,29 @@ if (obj instanceof Buffer) { | ||
function last(suite) { | ||
return suite === suite.parent.suites.slice(-1)[0]; | ||
} | ||
function formatDuration(duration) { | ||
function formatMillisec(msec) { | ||
return msec ? '.' + pad(msec, 3, '0') : ''; | ||
} | ||
var _duration = new Date(duration); | ||
if (duration < 1000) { | ||
return duration + 'ms'; | ||
} | ||
if (duration < 60 * 1000) { | ||
return _duration.getUTCSeconds() + formatMillisec(_duration.getUTCMilliseconds()) + 's'; | ||
} | ||
if (duration < 60 * 60 * 1000) { | ||
return _duration.getUTCMinutes() + ':' + | ||
pad(_duration.getUTCSeconds(), 2, '0') + formatMillisec(_duration.getUTCMilliseconds()); | ||
} | ||
return _duration.getUTCHours() + ':' + | ||
pad(_duration.getUTCMinutes(), 2, '0') + ':' + | ||
pad(_duration.getUTCSeconds(), 2, '0') + formatMillisec(_duration.getUTCMilliseconds()); | ||
} | ||
runner.on('start', function() { | ||
styles = styles[global.getTartareOptions('theme') || 'dark']; | ||
styles = styles[(global.getTartareOptions && global.getTartareOptions('theme')) || 'dark']; | ||
if (!GherkinBase.Base.useColors) { | ||
@@ -218,12 +249,9 @@ _.map(styles, function(value, key) { | ||
console.log(indent( | ||
(feature.pending ? styles.featureTitlePending : styles.featureTitle)(getDecoratedTitle(feature)) + os.EOL) | ||
(feature.pending ? styles.featureTitlePending : styles.featureTitle)(getDecoratedTitle(feature))) | ||
); | ||
feature.subtitle.forEach(function(subtitleLine) { | ||
console.log(indent( | ||
'\t' + (feature.pending ? styles.featureSubtitlePending : styles.featureSubtitle)(subtitleLine)) | ||
' ' + (feature.pending ? styles.featureSubtitlePending : styles.featureSubtitle)(subtitleLine)) | ||
); | ||
}); | ||
if (feature.subtitle.length) { | ||
console.log(); | ||
} | ||
if (feature.suites.length) { | ||
@@ -249,19 +277,27 @@ console.log(); | ||
runner.on('feature end', function(feature) { | ||
if (!feature.pending) { | ||
console.log(indent(styles.duration('Feature duration: ' + formatDuration(feature.duration)))); | ||
} | ||
--indents; | ||
if (!feature.suites.length) { | ||
console.log(); | ||
} else if (!feature.suites[feature.suites.length - 1].suites.length) { | ||
// If the feature ends with an unimplemented scenario | ||
console.log(); | ||
} | ||
console.log(); | ||
}); | ||
runner.on('scenario end', function(scenario) { | ||
if (!scenario.pending) { | ||
console.log(indent(styles.duration('Scenario duration: ' + formatDuration(scenario.duration)))); | ||
} | ||
--indents; | ||
console.log(); | ||
if (!last(scenario) || !scenario.suites.length) { | ||
console.log(); | ||
} | ||
}); | ||
runner.on('variant end', function(variant) { | ||
if (!variant.dummy && !variant.pending) { | ||
console.log(indent(styles.duration('Variant duration: ' + formatDuration(variant.duration)))); | ||
} | ||
--indents; | ||
console.log(); | ||
if (!last(variant) || variant.pending) { | ||
console.log(); | ||
} | ||
}); | ||
@@ -278,3 +314,3 @@ | ||
styles.symbolPending(' ◊ ') + | ||
styles.stepLabelPending(pad(title.substring(0, pos), 6) + ': ') + | ||
styles.stepLabelPending(pad(title.substring(0, pos), 5) + ': ') + | ||
styles.stepTextPending(title.substring(pos + 2)))); | ||
@@ -287,3 +323,3 @@ }); | ||
styles.symbol(' ◦ ') + | ||
styles.stepLabel(pad(step.title.substring(0, pos), 6) + ': ') + | ||
styles.stepLabel(pad(step.title.substring(0, pos), 5) + ': ') + | ||
styles.stepText(step.title.substring(pos + 2)))); | ||
@@ -297,5 +333,5 @@ }); | ||
styles.symbol(' ' + GherkinBase.Base.symbols.ok + ' ') + | ||
styles.stepLabel(pad(step.title.substring(0, pos), 6) + ': ') + | ||
styles.stepLabel(pad(step.title.substring(0, pos), 5) + ': ') + | ||
styles.stepText(step.title.substring(pos + 2)) + | ||
styles.duration(' (' + step.duration + 'ms)'))); | ||
styles.duration(' (' + formatDuration(step.duration) + ')'))); | ||
}); | ||
@@ -325,11 +361,11 @@ | ||
// REPORT | ||
console.log(pad('', 13) + '| ' + styles.symbol('passed') + ' | ' + styles.symbolFailed('failed') + ' | ' + | ||
console.log(pad('', 12) + '| ' + styles.symbol('passed') + ' | ' + styles.symbolFailed('failed') + ' | ' + | ||
' TOTAL | ' + styles.symbolManual('manual') + ' |'); | ||
console.log(' ' + pad('', 48, '-')); | ||
console.log(' ' + pad('', 47, '-')); | ||
_.each(self.stats, function(value, key) { | ||
console.log(' ' + pad(key[0].toUpperCase() + key.slice(1), 10) + ' | ' + | ||
styles.symbol(pad(value.passed, 7)) + ' | ' + | ||
styles.symbolFailed(pad(value.failed, 7)) + ' | ' + | ||
pad(value.passed + value.failed, 7) + ' | ' + | ||
styles.symbolManual(pad(value.manual, 7)) + ' | ' | ||
console.log(' ' + pad(key[0].toUpperCase() + key.slice(1), 9) + ' | ' + | ||
styles.symbol(pad(value.passed, 6)) + ' | ' + | ||
styles.symbolFailed(pad(value.failed, 6)) + ' | ' + | ||
pad(value.passed + value.failed, 6) + ' | ' + | ||
styles.symbolManual(pad(value.manual, 6)) + ' | ' | ||
); | ||
@@ -363,4 +399,3 @@ }); | ||
str = str.slice(0, -2) + ']'; | ||
} | ||
else { | ||
} else { | ||
str += ']'; | ||
@@ -371,2 +406,5 @@ } | ||
console.log(styles.duration(' Total duration: ' + formatDuration(self.duration))); | ||
console.log(); | ||
// FAILURES DETAIL | ||
@@ -373,0 +411,0 @@ if (self.failures.length) { |
{ | ||
"name": "tartare", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "Gherkin-like BDD testing framework for JavaScript based on Mocha", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
# RELEASE NOTES | ||
## v0.8.0 / 13 Feb 2015 | ||
* Fixed gherkin-md reporter to finish without calling `process.exit`. | ||
* Added execution time for variants, scenarios, features and for the whole suite in the `gherkin` reporter. | ||
* Added a new `sleep` function that works like `setTimeout` but expect the `cb` in the last argument and | ||
it is ready to be used as a synchronous function. | ||
## v0.7.0 / 11 Jan 2015 | ||
@@ -4,0 +10,0 @@ * From now on, `tartare` package contains only the framework functionality, while the rest of goodies are spread among |
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
87740
1828
0