Comparing version 0.9.0 to 1.0.0
/* | ||
Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U | ||
Copyright 2015-2016 Telefonica Investigación y Desarrollo, S.A.U | ||
@@ -5,0 +5,0 @@ This file is part of Tartare. |
/* | ||
Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U | ||
Copyright 2015-2016 Telefonica Investigación y Desarrollo, S.A.U | ||
@@ -24,4 +24,2 @@ This file is part of Tartare. | ||
/* eslint-disable dot-notation */ | ||
var Suite = require('mocha/lib/suite'), | ||
@@ -95,3 +93,3 @@ Test = require('mocha/lib/test'), | ||
suite.pending = true; | ||
suite.tags['manual'] = true; | ||
suite.tags.manual = true; | ||
} else { | ||
@@ -117,3 +115,3 @@ suite.file = file; | ||
if (options.only) { | ||
suite.tags['only'] = true; | ||
suite.tags.only = true; | ||
mocha.options.grep = 'only'; | ||
@@ -160,5 +158,5 @@ } | ||
suite.pending = true; | ||
suite.tags['manual'] = true; | ||
suite.tags.manual = true; | ||
suite.parent.hasManualChildren = true; | ||
suite.parent.tags['manual'] = true; | ||
suite.parent.tags.manual = true; | ||
} else { | ||
@@ -174,3 +172,3 @@ suite.file = file; | ||
suite.beforeAll('beforeEachScenario', beforeEachScenarioFn); | ||
var hooksArray = suite['_beforeAll']; | ||
var hooksArray = suite._beforeAll; | ||
hooksArray[hooksArray.length - 1].subtype = 'beforeEachScenario'; | ||
@@ -180,3 +178,3 @@ }); | ||
suite.afterAll('afterEachScenario', afterEachScenarioFn); | ||
var hooksArray = suite['_afterAll']; | ||
var hooksArray = suite._afterAll; | ||
hooksArray[hooksArray.length - 1].subtype = 'afterEachScenario'; | ||
@@ -212,3 +210,3 @@ }); | ||
if (options.only) { | ||
suite.tags['only'] = true; | ||
suite.tags.only = true; | ||
mocha.options.grep = 'only'; | ||
@@ -229,6 +227,6 @@ } | ||
if (suite.manual) { | ||
suite.tags['manual'] = true; | ||
suite.tags.manual = true; | ||
suite.parent.hasManualChildren = suite.parent.parent.hasManualChildren = true; | ||
suite.parent.tags['manual'] = true; | ||
suite.parent.parent.tags['manual'] = true; | ||
suite.parent.tags.manual = true; | ||
suite.parent.parent.tags.manual = true; | ||
} | ||
@@ -255,3 +253,3 @@ if (suite.manual || variant.minorBug) { | ||
if (variant.only) { | ||
suite.tags['only'] = true; | ||
suite.tags.only = true; | ||
mocha.options.grep = 'only'; | ||
@@ -305,5 +303,5 @@ } | ||
test.parent.parent.parent.hasManualChildren = true; | ||
test.parent.tags['manual'] = true; | ||
test.parent.parent.tags['manual'] = true; | ||
test.parent.parent.parent.tags['manual'] = true; | ||
test.parent.tags.manual = true; | ||
test.parent.parent.tags.manual = true; | ||
test.parent.parent.parent.tags.manual = true; | ||
} | ||
@@ -310,0 +308,0 @@ |
/* | ||
Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U | ||
Copyright 2015-2016 Telefonica Investigación y Desarrollo, S.A.U | ||
@@ -24,5 +24,2 @@ This file is part of Tartare. | ||
/* eslint-disable no-new-wrappers */ | ||
/* eslint-disable no-extend-native */ | ||
var jsep = require('jsep'), | ||
@@ -220,3 +217,2 @@ util = require('util'); | ||
/* eslint-disable dot-notation */ | ||
/** | ||
@@ -232,3 +228,3 @@ * Add methods 'majorBug' and 'minorBug' to the Mocha Suite prototype so these methods can be used | ||
_setAttrDeepUp(this, 'buggy', true); | ||
this.tags['bug'] = true; | ||
this.tags.bug = true; | ||
return this; | ||
@@ -242,6 +238,5 @@ }; | ||
_setAttrDeepDown(this, 'pending', true); | ||
this.tags['bug'] = true; | ||
this.tags.bug = true; | ||
return this; | ||
}; | ||
/* eslint-enable dot-notation */ | ||
@@ -248,0 +243,0 @@ /** |
/* | ||
Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U | ||
Copyright 2015-2016 Telefonica Investigación y Desarrollo, S.A.U | ||
@@ -5,0 +5,0 @@ This file is part of Tartare. |
/* | ||
Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U | ||
Copyright 2015-2016 Telefonica Investigación y Desarrollo, S.A.U | ||
@@ -24,5 +24,6 @@ This file is part of Tartare. | ||
/* eslint no-shadow: 0 */ | ||
var util = require('util'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
mkdirp = require('mkdirp'), | ||
GherkinBase = require('./gherkin-base'); | ||
@@ -33,11 +34,18 @@ | ||
*/ | ||
function GherkinMdReporter(runner) { | ||
function GherkinMdReporter(runner, options) { | ||
GherkinBase.call(this, runner); | ||
var bugIdPrefix = global.getTartareOptions('bugidLink') || null; | ||
if (bugIdPrefix && bugIdPrefix.indexOf('%s') === -1) { | ||
bugIdPrefix += '%s'; | ||
var self = this; | ||
if (options.reporterOptions && options.reporterOptions.output) { | ||
mkdirp.sync(path.dirname(options.reporterOptions.output)); | ||
self.fileStream = fs.createWriteStream(options.reporterOptions.output); | ||
} | ||
var stats = { // These stats are calculated over the Mocha's tree, without running the tests | ||
self.bugIdPrefix = (options.reporterOptions && options.reporterOptions.bugidLink) || options.bugidLink || null; | ||
if (self.bugIdPrefix && self.bugIdPrefix.indexOf('%s') === -1) { | ||
self.bugIdPrefix += '%s'; | ||
} | ||
self.staticStats = { // These stats are calculated over the Mocha's tree, without running the tests | ||
features: {passed: 0, failed: 0, manual: 0}, | ||
@@ -48,8 +56,17 @@ scenarios: {passed: 0, failed: 0, manual: 0}, | ||
}; | ||
var majorBugs = {}; | ||
var minorBugs = {}; | ||
self.majorBugs = {}; | ||
self.minorBugs = {}; | ||
function write(line) { | ||
line = line || ''; | ||
if (self.fileStream) { | ||
self.fileStream.write(line + '\n'); | ||
} else { | ||
console.log(line); | ||
} | ||
} | ||
function getLinkFromBugId(bugId) { | ||
if (bugIdPrefix) { | ||
return '[' + bugId + '](' + bugIdPrefix.replace('%s', bugId) + ')'; | ||
if (self.bugIdPrefix) { | ||
return '[' + bugId + '](' + self.bugIdPrefix.replace('%s', bugId) + ')'; | ||
} else { | ||
@@ -93,16 +110,16 @@ return bugId; | ||
function printStats(stats) { | ||
console.log('| | Passed | Failed | TOTAL | Manual |'); | ||
console.log('|---|-------:|-------:|------:|-------:|'); | ||
console.log('| Features (US) | ' + stats.features.passed + ' | ' + stats.features.failed + ' | ' + | ||
write('| | Passed | Failed | TOTAL | Manual |'); | ||
write('|---|-------:|-------:|------:|-------:|'); | ||
write('| Features (US) | ' + stats.features.passed + ' | ' + stats.features.failed + ' | ' + | ||
(stats.features.passed + stats.features.failed) + ' | ' + stats.features.manual + ' | '); | ||
console.log('| Scenarios (TC) | ' + stats.scenarios.passed + ' | ' + stats.scenarios.failed + ' | ' + | ||
write('| Scenarios (TC) | ' + stats.scenarios.passed + ' | ' + stats.scenarios.failed + ' | ' + | ||
(stats.scenarios.passed + stats.scenarios.failed) + ' | ' + stats.scenarios.manual + ' | '); | ||
console.log('| Variants (DS) | ' + stats.variants.passed + ' | ' + stats.variants.failed + ' | ' + | ||
write('| Variants (DS) | ' + stats.variants.passed + ' | ' + stats.variants.failed + ' | ' + | ||
(stats.variants.passed + stats.variants.failed) + ' | ' + stats.variants.manual + ' | '); | ||
console.log('| Steps | | | ' + stats.steps.total + ' | ' + stats.steps.manual + ' | '); | ||
console.log(); | ||
write('| Steps | | | ' + stats.steps.total + ' | ' + stats.steps.manual + ' | '); | ||
write(); | ||
} | ||
function printTOC(rootSuite) { | ||
console.log('# TOC'); | ||
write('# TOC'); | ||
rootSuite.suites.forEach(function(feature) { | ||
@@ -112,3 +129,3 @@ if (feature.type !== 'feature') { | ||
} | ||
console.log('- [' + feature.title + '](#' + slug(feature.fullTitle()) + ')'); | ||
write('- [' + feature.title + '](#' + slug(feature.fullTitle()) + ')'); | ||
feature.suites.forEach(function(scenario) { | ||
@@ -118,7 +135,7 @@ if (scenario.type !== 'scenario') { | ||
} | ||
console.log(' - [' + scenario.title + '](#' + slug(scenario.fullTitle()) + ')'); | ||
write(' - [' + scenario.title + '](#' + slug(scenario.fullTitle()) + ')'); | ||
}); | ||
}); | ||
console.log(); | ||
console.log('---'); | ||
write(); | ||
write('---'); | ||
} | ||
@@ -128,11 +145,11 @@ | ||
function _printBuggySuite(suite) { | ||
console.log(' - [' + suite.title + '](#' + slug(suite.fullTitle()) + ')'); | ||
write(' - [' + suite.title + '](#' + slug(suite.fullTitle()) + ')'); | ||
} | ||
console.log(); | ||
console.log('# ' + title); | ||
write(); | ||
write('# ' + title); | ||
for (var bugId in bugs) { | ||
if (bugs.hasOwnProperty(bugId)) { | ||
console.log('- Bug Id: ' + getLinkFromBugId(bugId) + ':'); | ||
write('- Bug Id: ' + getLinkFromBugId(bugId) + ':'); | ||
bugs[bugId].forEach(_printBuggySuite); | ||
@@ -145,4 +162,4 @@ } | ||
// Ensure the report is not affected by some process writing in stdout | ||
console.log(); | ||
console.log(); | ||
write(); | ||
write(); | ||
@@ -218,8 +235,8 @@ // Modify Mocha's tree to remove suites that do not match the filter | ||
if (feature.buggy) { | ||
stats.features.failed++; | ||
self.staticStats.features.failed++; | ||
} else { | ||
stats.features.passed++; | ||
self.staticStats.features.passed++; | ||
} | ||
if (feature.manual) { | ||
stats.features.manual++; | ||
self.staticStats.features.manual++; | ||
} | ||
@@ -229,7 +246,7 @@ if (feature.bugId && feature.bugId !== feature.parent.bugId) { | ||
if (feature.buggy) { | ||
majorBugs[feature.bugId] = majorBugs[feature.bugId] || []; | ||
majorBugs[feature.bugId].push(feature); | ||
self.majorBugs[feature.bugId] = self.majorBugs[feature.bugId] || []; | ||
self.majorBugs[feature.bugId].push(feature); | ||
} else { | ||
minorBugs[feature.bugId] = minorBugs[feature.bugId] || []; | ||
minorBugs[feature.bugId].push(feature); | ||
self.minorBugs[feature.bugId] = self.minorBugs[feature.bugId] || []; | ||
self.minorBugs[feature.bugId].push(feature); | ||
} | ||
@@ -243,8 +260,8 @@ } | ||
if (scenario.buggy) { | ||
stats.scenarios.failed++; | ||
self.staticStats.scenarios.failed++; | ||
} else { | ||
stats.scenarios.passed++; | ||
self.staticStats.scenarios.passed++; | ||
} | ||
if (scenario.manual) { | ||
stats.scenarios.manual++; | ||
self.staticStats.scenarios.manual++; | ||
} | ||
@@ -254,7 +271,7 @@ if (scenario.bugId && scenario.bugId !== scenario.parent.bugId) { | ||
if (scenario.buggy) { | ||
majorBugs[scenario.bugId] = majorBugs[scenario.bugId] || []; | ||
majorBugs[scenario.bugId].push(scenario); | ||
self.majorBugs[scenario.bugId] = self.majorBugs[scenario.bugId] || []; | ||
self.majorBugs[scenario.bugId].push(scenario); | ||
} else { | ||
minorBugs[scenario.bugId] = minorBugs[scenario.bugId] || []; | ||
minorBugs[scenario.bugId].push(scenario); | ||
self.minorBugs[scenario.bugId] = self.minorBugs[scenario.bugId] || []; | ||
self.minorBugs[scenario.bugId].push(scenario); | ||
} | ||
@@ -268,8 +285,8 @@ } | ||
if (variant.buggy) { | ||
stats.variants.failed++; | ||
self.staticStats.variants.failed++; | ||
} else { | ||
stats.variants.passed++; | ||
self.staticStats.variants.passed++; | ||
} | ||
if (variant.manual) { | ||
stats.variants.manual++; | ||
self.staticStats.variants.manual++; | ||
} | ||
@@ -279,7 +296,7 @@ if (variant.bugId && variant.bugId !== variant.parent.bugId && !variant.dummy) { | ||
if (variant.buggy) { | ||
majorBugs[variant.bugId] = majorBugs[variant.bugId] || []; | ||
majorBugs[variant.bugId].push(variant); | ||
self.majorBugs[variant.bugId] = self.majorBugs[variant.bugId] || []; | ||
self.majorBugs[variant.bugId].push(variant); | ||
} else { | ||
minorBugs[variant.bugId] = minorBugs[variant.bugId] || []; | ||
minorBugs[variant.bugId].push(variant); | ||
self.minorBugs[variant.bugId] = self.minorBugs[variant.bugId] || []; | ||
self.minorBugs[variant.bugId].push(variant); | ||
} | ||
@@ -292,5 +309,5 @@ } | ||
} | ||
stats.steps.total++; | ||
self.staticStats.steps.total++; | ||
if (step.manual) { | ||
stats.steps.manual++; | ||
self.staticStats.steps.manual++; | ||
} | ||
@@ -302,3 +319,3 @@ }); | ||
printStats(stats); | ||
printStats(self.staticStats); | ||
@@ -316,4 +333,4 @@ printTOC(runner.suite); | ||
} | ||
console.log('<a name="' + slug(feature.fullTitle()) + '"></a>'); | ||
console.log('## ' + title); | ||
write('<a name="' + slug(feature.fullTitle()) + '"></a>'); | ||
write('## ' + title); | ||
feature.subtitle.forEach(function(line) { | ||
@@ -323,5 +340,5 @@ if (feature.pending) { | ||
} | ||
console.log('- ' + line); | ||
write('- ' + line); | ||
}); | ||
console.log(); | ||
write(); | ||
@@ -336,4 +353,4 @@ feature.suites.forEach(function(scenario) { | ||
} | ||
console.log('<a name="' + slug(scenario.fullTitle()) + '"></a>'); | ||
console.log('### ' + title); | ||
write('<a name="' + slug(scenario.fullTitle()) + '"></a>'); | ||
write('### ' + title); | ||
@@ -349,4 +366,4 @@ scenario.suites.forEach(function(variant) { | ||
} | ||
console.log('<a name="' + slug(variant.fullTitle()) + '"></a>'); | ||
console.log('**' + title + '**'); | ||
write('<a name="' + slug(variant.fullTitle()) + '"></a>'); | ||
write('**' + title + '**'); | ||
} | ||
@@ -376,25 +393,25 @@ | ||
} | ||
console.log(str); | ||
write(str); | ||
}); | ||
console.log(); | ||
write(); | ||
}); | ||
if (scenario.pending) { | ||
console.log(); | ||
write(); | ||
} | ||
}); | ||
if (feature.pending) { | ||
console.log(); | ||
write(); | ||
} | ||
console.log('---'); | ||
write('---'); | ||
}); | ||
console.log(); | ||
write(); | ||
if (Object.keys(majorBugs).length) { | ||
printBugs(majorBugs, 'Major Bugs'); | ||
console.log(); | ||
if (Object.keys(self.majorBugs).length) { | ||
printBugs(self.majorBugs, 'Major Bugs'); | ||
write(); | ||
} | ||
if (Object.keys(minorBugs).length) { | ||
printBugs(minorBugs, 'Minor Bugs'); | ||
console.log(); | ||
if (Object.keys(self.minorBugs).length) { | ||
printBugs(self.minorBugs, 'Minor Bugs'); | ||
write(); | ||
} | ||
@@ -409,2 +426,15 @@ | ||
/** | ||
* Close the stream if it's a file | ||
*/ | ||
GherkinMdReporter.prototype.done = function(failures, fn) { | ||
if (this.fileStream) { | ||
this.fileStream.end(function() { | ||
fn(failures); | ||
}); | ||
} else { | ||
fn(failures); | ||
} | ||
}; | ||
module.exports = GherkinMdReporter; |
/* | ||
Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U | ||
Copyright 2015-2016 Telefonica Investigación y Desarrollo, S.A.U | ||
@@ -24,8 +24,4 @@ This file is part of Tartare. | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable new-cap */ | ||
var util = require('util'), | ||
os = require('os'), | ||
_ = require('underscore'), | ||
clc = require('cli-color'), | ||
@@ -233,7 +229,7 @@ GherkinBase = require('./gherkin-base'); | ||
runner.on('start', function() { | ||
styles = styles[(global.getTartareOptions && global.getTartareOptions('theme')) || 'dark']; | ||
styles = styles[GherkinBase.theme]; | ||
if (!GherkinBase.Base.useColors) { | ||
_.map(styles, function(value, key) { | ||
styles[key] = function(str) { return str; }; | ||
}); | ||
for (var style in styles) { | ||
styles[style] = function(str) { return str; }; | ||
} | ||
} | ||
@@ -316,7 +312,9 @@ | ||
runner.on('step', function(step) { | ||
var pos = step.title.indexOf(': '); | ||
process.stdout.write(indent( | ||
styles.symbol(' ◦ ') + | ||
styles.stepLabel(pad(step.title.substring(0, pos), 5) + ': ') + | ||
styles.stepText(step.title.substring(pos + 2)))); | ||
if (GherkinBase.interactive) { | ||
var pos = step.title.indexOf(': '); | ||
process.stdout.write(indent( | ||
styles.symbol(' ◦ ') + | ||
styles.stepLabel(pad(step.title.substring(0, pos), 5) + ': ') + | ||
styles.stepText(step.title.substring(pos + 2)))); | ||
} | ||
}); | ||
@@ -326,3 +324,5 @@ | ||
var pos = step.title.indexOf(': '); | ||
GherkinBase.Base.cursor.CR(); | ||
if (GherkinBase.interactive) { | ||
GherkinBase.Base.cursor.CR(); | ||
} | ||
console.log(indent( | ||
@@ -337,3 +337,5 @@ styles.symbol(' ' + GherkinBase.Base.symbols.ok + ' ') + | ||
var pos = step.title.indexOf(': '); | ||
GherkinBase.Base.cursor.CR(); | ||
if (GherkinBase.interactive) { | ||
GherkinBase.Base.cursor.CR(); | ||
} | ||
console.log(indent( | ||
@@ -347,3 +349,5 @@ styles.symbolFailed(' ' + GherkinBase.Base.symbols.err + ' ' + self.failures.length + ') ') + | ||
runner.on('hook fail', function(hook, err) { | ||
GherkinBase.Base.cursor.CR(); | ||
if (GherkinBase.interactive) { | ||
GherkinBase.Base.cursor.CR(); | ||
} | ||
console.log(indent( | ||
@@ -362,10 +366,11 @@ styles.symbolFailed(' ' + GherkinBase.Base.symbols.err + ' ' + self.failures.length + ') ') + | ||
console.log(' ' + pad('', 47, '-')); | ||
_.each(self.stats, function(value, key) { | ||
for (var key in self.stats) { | ||
var value = self.stats[key]; | ||
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)) + ' | ' | ||
styles.symbol(pad(value.passed, 6)) + ' | ' + | ||
styles.symbolFailed(pad(value.failed, 6)) + ' | ' + | ||
pad(value.passed + value.failed, 6) + ' | ' + | ||
styles.symbolManual(pad(value.manual, 6)) + ' | ' | ||
); | ||
}); | ||
} | ||
console.log(); | ||
@@ -388,14 +393,12 @@ | ||
str = ' · Coverage (Σ test-variants/feature): ['; | ||
if (_.size(self.variantsPerFeature)) { | ||
_.each(self.variantsPerFeature, function(value, key) { | ||
str += value.total; | ||
if (value.manual) { | ||
str += ' (' + value.manual + ' manual)'; | ||
} | ||
str += ', '; | ||
}); | ||
str = str.slice(0, -2) + ']'; | ||
} else { | ||
str += ']'; | ||
var coverage = []; | ||
for (var feature in self.variantsPerFeature) { | ||
var variants = self.variantsPerFeature[feature]; | ||
var s = variants.total.toString(); | ||
if (variants.manual) { | ||
s += ' (' + variants.manual + ' manual)'; | ||
} | ||
coverage.push(s); | ||
} | ||
str += coverage.join(', ') + ']'; | ||
console.log(str); | ||
@@ -402,0 +405,0 @@ console.log(); |
/* | ||
Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U | ||
Copyright 2015-2016 Telefonica Investigación y Desarrollo, S.A.U | ||
@@ -25,2 +25,3 @@ This file is part of Tartare. | ||
var Mocha = require('mocha'), | ||
GherkinBase = require('./reporters/gherkin-base'), | ||
path = require('path'); | ||
@@ -45,2 +46,4 @@ | ||
* - `reporter` reporter name, defaults to `tartare.reporters.gherkin` | ||
* - `reporterOptions` reporter-specific options (It can be an object or a string with a list of key=value pairs | ||
* separated by commas) | ||
* - `timeout` timeout in milliseconds | ||
@@ -50,2 +53,4 @@ * - `bail` bail on the first step failure | ||
* - `useColors` set whether colors can be used on console reporters | ||
* - `theme`: set the color theme to be used with the gherkin reporter (dark or clear) | ||
* - `interactive` set whether the interactive features are enabled or not | ||
* - `enableTimeouts` enable timeouts | ||
@@ -63,5 +68,7 @@ * - Any other options will be available through the `getTartareOptions` function | ||
this.options.useColors = this.options.useColors !== false; | ||
this.options.theme = this.options.theme || 'dark'; | ||
this.options.interactive = this.options.interactive !== false; | ||
this.options.enableTimeouts = this.options.enableTimeouts !== false; | ||
// Read Tartare env vars | ||
// Read Tartare env vars (some of them could overwrite the former options) | ||
for (var envName in process.env) { | ||
@@ -76,5 +83,42 @@ if (process.env.hasOwnProperty(envName)) { | ||
// Sanitize opts | ||
this.options.timeout = parseInt(this.options.timeout); | ||
if (isNaN(this.options.timeout)) { | ||
throw new Error('Invalid timeout. It must be a number.'); | ||
} | ||
if (this.options.filter && !/^[A-Za-z0-9_ ,+&|()-]+$/.test(this.options.filter)) { | ||
throw new Error('Invalid filter "' + this.options.filter + '". See tartare -h for more info.'); | ||
} | ||
if (!/^(dark|clear)$/.test(this.options.theme)) { | ||
throw new Error('Invalid theme "' + this.options.theme + '". Only "dark" and "clear" are allowed.'); | ||
} | ||
['bail', 'useColors', 'interactive', 'enableTimeouts'].forEach(function(optName) { | ||
this.options[optName] = this.options[optName] != 0; // Force boolean from values 0 or 1 | ||
}, this); | ||
if (this.options.reporterOptions && typeof this.options.reporterOptions === 'string') { | ||
// Convert a comma-separated list of key=value pairs to an object | ||
var reporterOptions = this.options.reporterOptions; | ||
this.options.reporterOptions = {}; | ||
reporterOptions.split(',').forEach(function(repOpt) { | ||
var repOptNV = repOpt.split('='); | ||
var optName = repOptNV[0]; | ||
if (!optName.length) { | ||
throw new Error('Invalid reporter option "' + repOpt + '". Missing option name'); | ||
} | ||
if (repOptNV.length === 1) { // optName w/o optValue | ||
this.options.reporterOptions[optName] = true; | ||
} else { | ||
var optValue = repOptNV.slice(1).join('='); | ||
if (!optValue.length) { | ||
throw new Error('Invalid reporter option "' + repOpt + '". Missing option value'); | ||
} | ||
this.options.reporterOptions[optName] = optValue; | ||
} | ||
}, this); | ||
} | ||
var mochaOpts = { | ||
ui: path.join(__dirname, './interfaces/gherkin'), | ||
reporter: require('./reporters/' + this.options.reporter), | ||
reporterOptions: this.options.reporterOptions, | ||
timeout: this.options.timeout, | ||
@@ -141,3 +185,5 @@ bail: this.options.bail, | ||
Tartare.prototype.run = function(fn) { | ||
GherkinBase.theme = this.options.theme; | ||
GherkinBase.interactive = this.options.interactive; | ||
return this.mocha.run(fn); | ||
}; |
{ | ||
"name": "tartare", | ||
"version": "0.9.0", | ||
"version": "1.0.0", | ||
"description": "Gherkin-like BDD testing framework for JavaScript based on Mocha", | ||
@@ -34,12 +34,12 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"cli-color": "1.0.0", | ||
"jsep": "0.3.0", | ||
"mocha": "2.2.5", | ||
"synchronize": "0.9.11", | ||
"underscore": "1.8.3" | ||
"cli-color": "^1.1.0", | ||
"jsep": "^0.3.0", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^2.4.5", | ||
"synchronize": "^0.9.15" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^0.22.1", | ||
"jscs": "^1.13.1" | ||
"eslint": "^2.9.0", | ||
"jscs": "^3.0.3" | ||
} | ||
} |
100
README.md
@@ -9,3 +9,4 @@ # TARTARE - Code Driven Testing | ||
[tartare-collections](https://github.com/telefonicaid/tartare-collections/) | | ||
[tartare-logs](https://github.com/telefonicaid/tartare-logs/) | ||
[tartare-logs](https://github.com/telefonicaid/tartare-logs/) | | ||
[protractor-tartare](https://github.com/telefonicaid/protractor-tartare/) | ||
@@ -313,3 +314,3 @@ --- | ||
At the end it prints some stats about the *features*, *scenarios*, *variants* and *steps* your suite have, and how many | ||
At the end it prints some stats about the *features*, *scenarios*, *variants* and *steps* your suite has, and how many | ||
of them have passed or failed, or how many are marked as [manual](#manual-tests). It also gives you some metrics | ||
@@ -337,4 +338,4 @@ about your suite. Keep in mind that *features* having the same description are counted as the same *feature*. | ||
### gherkin-md | ||
When choosing the Markdown reporter, stats and test description is produced using the [GFM (GitHub Flavored | ||
Markdown)](https://help.github.com/articles/github-flavored-markdown/). This reporter do not really execute | ||
When choosing the Markdown reporter, stats and test description is produced by using the [GFM (GitHub Flavored | ||
Markdown)](https://help.github.com/articles/github-flavored-markdown/). This reporter do not actually execute | ||
the test suite, but only reads all your *features*, *scenarios*, *variants* and *steps* to generate the report, so | ||
@@ -349,3 +350,3 @@ you get the report in a fraction of a second. | ||
The report is written to the stdout, so you would want to redirect it to a file: | ||
By default, the report is written to the stdout, so you would want to redirect it to a file: | ||
@@ -356,2 +357,15 @@ ```bash | ||
But you can use the `output` reporter option to set the file where the report will be written: | ||
```bash | ||
$ tartare tests.js --reporter gherkin-md --reporter-options output=report.md | ||
``` | ||
You can also use the `bugidLink` reporter option to set the base URL of your bug tracking system | ||
(see [Bug Management](#bug-management) below): | ||
```bash | ||
$ tartare tests.js --reporter gherkin-md --reporter-options output=report.md,bugidLink=http://bugtrackingsystem/ | ||
``` | ||
![Markdown reporter output](http://telefonicaid.github.io/tartare/img/markdown-reporter.png) | ||
@@ -524,8 +538,9 @@ | ||
If you run Tartare with the `--bugid-link` parameter passing the base URL of your bug tracking system, | ||
the markdown report will include links by appending the bug id passed to `majorBug`/`minorBug` | ||
to the base url. If such a base url has the `%s` placeholder, the bug id will be placed there. | ||
When using the [markdown reporter](#gherkin-md) you can pass the `bugidLink` reporter option with the base URL of | ||
your bug tracking system, so the bug ids will be links formed by appending the bug id passed to the | ||
`majorBug`/`minorBug` functions to the base url. If such a base url has the `%s` placeholder, | ||
the bug id will be placed there. | ||
```bash | ||
$ tartare tests.js --reporter gherkin-md --bugid-link "http://bugtrackingsystem/%s" > report.md | ||
$ tartare tests.js --reporter gherkin-md --reporter-options output=report.md,bugidLink=http://bugtrackingsystem/%s | ||
``` | ||
@@ -602,16 +617,18 @@ | ||
-h, --help output usage information | ||
-V, --version output the version number | ||
-r, --require require the given module | ||
-R, --reporter <name> specify the reporter to use [gherkin] | ||
-t, --timeout <ms> set test timeout in milliseconds [10000] | ||
-f, --filter <filter_str> run only tests matching <filter_str> | ||
-c, --colors force enabling of colors | ||
-C, --no-colors force disabling of colors | ||
--theme (dark|clear) set the color theme to be used with the gherkin reporter | ||
-B, --no-bail prevent from bailing after first step failure | ||
--no-exit require a clean shutdown of the event loop: Tartare will not call process.exit | ||
--no-timeouts disables timeouts | ||
--recursive include sub directories | ||
--reporters display available reporters | ||
-h, --help output usage information | ||
-V, --version output the version number | ||
-r, --require require the given module | ||
-R, --reporter <name> specify the reporter to use [gherkin] | ||
-O, --reporter-options <k=v,k2=v2,...> reporter-specific options | ||
-t, --timeout <ms> set test timeout in milliseconds [10000] | ||
-f, --filter <filter_str> run only tests matching <filter_str> | ||
-c, --colors force enabling of colors | ||
-C, --no-colors force disabling of colors | ||
--theme (dark|clear) set the color theme to be used with the gherkin reporter [dark] | ||
--no-interactive disable interactive features | ||
-B, --no-bail prevent from bailing after first step failure | ||
--no-exit require a clean shutdown of the event loop: Tartare will not call process.exit | ||
--no-timeouts disables timeouts | ||
--recursive include sub directories | ||
--reporters display available reporters | ||
``` | ||
@@ -635,5 +652,10 @@ | ||
#### --theme | ||
When using the default *gherkin* reporter, this options allows you to choose the color theme. It can takes the values | ||
When using the default *gherkin* reporter, this options allows you to choose the color theme. It can take the value | ||
`dark` (default) for consoles with a dark background, or `clear` for consoles with a clear background. | ||
#### --no-interactive | ||
Disable interactive features such as printing step descriptions during their execution, reprinting the line once | ||
the step has finished with the final result and duration. This kind of features uses the console in a way that may not | ||
work properly on some console emulators. | ||
#### -B, --no-bail | ||
@@ -757,2 +779,3 @@ By default, Tartare stops the test suite after the first failure. If you want Tartare to execute the whole suite, | ||
* `reporter`: reporter name, defaults to `gherkin`. | ||
* `reporterOptions`: reporter-specific options. It can be an object or a string with a list of key=value pairs separated by commas. | ||
* `timeout`: timeout in milliseconds. | ||
@@ -762,5 +785,10 @@ * `bail`: bail on the first *step* failure. | ||
* `useColors`: set whether colors can be used on console reporters. | ||
* `theme`: set the color theme to be used with the gherkin reporter (dark or clear). | ||
* `interactive`: enable interactive features. | ||
* `enableTimeouts`: enable timeouts. | ||
* Any other options will be available through the `getTartareOptions` function. | ||
You can also use the following environment variables: `TARTARE_REPORTER`, `TARTARE_REPORTER_OPTIONS`, `TARTARE_TIMEOUT`, | ||
`TARTARE_BAIL`, `TARTARE_FILTER`, `TARTARE_USE_COLORS`, `TARTARE_THEME`, `TARTARE_INTERACTIVE`, `TARTARE_ENABLE_TIMEOUTS`. | ||
The `addFiles` method accepts both a string (a single file) or an array of strings. | ||
@@ -773,19 +801,19 @@ | ||
You can use Tartare as a testing framework with [Protractor](https://angular.github.io/protractor) in order to | ||
describe your tests using the Gherkin syntax while taken advantage of Protractor to test AngularJS applications. | ||
This feature is not integrated with Protractor upstream yet, so you need to use this | ||
[Protractor fork](https://github.com/telefonicaid/protractor/tree/tartare) (tartare brach) adding this | ||
dependency to your package.json file: | ||
describe your tests using the Gherkin syntax while taking advantage of Protractor to test AngularJS applications. | ||
```json | ||
"dependencies": { | ||
"protractor": "telefonicaid/protractor#tartare", | ||
"tartare": "latest" | ||
} | ||
Firstly, install both Protractor and the [Protractor Tartare Framework](https://github.com/telefonicaid/protractor-tartare) | ||
using `npm`: | ||
```sh | ||
$ npm install --save-dev protractor protractor-tartare tartare | ||
``` | ||
Then you have to set `tartare` as the testing framework in the Protractor config file. You can also pass options | ||
to Tartare with `tartareOpts`. | ||
Note that you still need Tartare as a dependency. | ||
Then you have to set `custom` as the testing framework in the Protractor config file and set the path to the | ||
Protractor Tartare Framework. You can also pass options to Tartare with `tartareOpts`. | ||
```javascript | ||
framework: 'tartare', | ||
framework: 'custom', | ||
frameworkPath: require.resolve('protractor-tartare'), | ||
tartareOpts: { | ||
@@ -792,0 +820,0 @@ reporter: 'gherkin', |
# RELEASE NOTES | ||
## v1.0.0 / 5 May 2016 | ||
* Added documentation about how to use Tartare with the new `protractor-tartare` package, which allows you to use | ||
Tartare along with Protractor (the [Protractor fork](https://github.com/telefonicaid/protractor/tree/tartare) | ||
won't be used anymore). | ||
* Every option that can be passed to the Tartare constructor can also be set using environment variables. | ||
* A new `interactive` option has been added to prevent reporters from using the console in a way that may break | ||
some console emulators. | ||
* The gherkin-md reporter supports reporter-specific options to set the output file and the `bugidLink` parameter. | ||
## v0.9.0 / 8 Jun 2015 | ||
@@ -67,4 +76,3 @@ * Added full documentation on the README file. | ||
* A new **tagging and filtering** functionality has been added to Tartare, so features, scenarios and variants | ||
can be tagged | ||
and then those tags can be used to filter test execution by using the `--filter` option. | ||
can be tagged and then those tags can be used to filter test execution by using the `--filter` option. | ||
- Tag features and scenarios by calling the `tag` method after its definition: | ||
@@ -71,0 +79,0 @@ `scenario('myscenario', function() { }).tag('mytag');` |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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 2 instances in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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 2 instances in 1 package
124554
1900
1
893
12
5
+ Addedmkdirp@^0.5.1
+ Addedansi-regex@2.1.1(transitive)
+ Addedcli-color@1.4.0(transitive)
+ Addeddebug@2.2.0(transitive)
+ Addedes6-weak-map@2.0.3(transitive)
+ Addedglob@3.2.11(transitive)
+ Addedgrowl@1.9.2(transitive)
+ Addedis-promise@2.2.2(transitive)
+ Addedjsep@0.3.5(transitive)
+ Addedmemoizee@0.4.17(transitive)
+ Addedminimatch@0.3.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.10.5.6(transitive)
+ Addedmocha@2.5.3(transitive)
+ Addedms@0.7.1(transitive)
+ Addedsupports-color@1.2.0(transitive)
+ Addedsynchronize@0.9.15(transitive)
+ Addedto-iso-string@0.0.2(transitive)
- Removedunderscore@1.8.3
- Removedansi-regex@1.1.1(transitive)
- Removedcli-color@1.0.0(transitive)
- Removedd@0.1.1(transitive)
- Removeddebug@2.0.0(transitive)
- Removedes6-iterator@0.1.3(transitive)
- Removedes6-symbol@2.0.1(transitive)
- Removedes6-weak-map@0.1.4(transitive)
- Removedglob@3.2.3(transitive)
- Removedgraceful-fs@2.0.3(transitive)
- Removedgrowl@1.8.1(transitive)
- Removedjsep@0.3.0(transitive)
- Removedmemoizee@0.3.10(transitive)
- Removedminimatch@0.2.14(transitive)
- Removedmkdirp@0.5.0(transitive)
- Removedmocha@2.2.5(transitive)
- Removedms@0.6.2(transitive)
- Removednext-tick@0.2.2(transitive)
- Removedsupports-color@1.2.1(transitive)
- Removedsynchronize@0.9.11(transitive)
- Removedunderscore@1.8.3(transitive)
Updatedcli-color@^1.1.0
Updatedjsep@^0.3.0
Updatedmocha@^2.4.5
Updatedsynchronize@^0.9.15