Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Tester and reporter supports multiple browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Tatarintsev committed Feb 20, 2014
1 parent d26d217 commit 3543786
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
12 changes: 10 additions & 2 deletions lib/reporters/tree.js
Expand Up @@ -6,6 +6,10 @@ var chalk = require('chalk');
var CHECK = '\u2713',
XMARK = '\u2718';

function tab(number) {
return new Array(number + 1).join(' ');
}

module.exports = function treeReporter(tester) {
var failed, passed;

Expand All @@ -17,12 +21,16 @@ module.exports = function treeReporter(tester) {
console.log(chalk.underline(planName));
});

tester.on('beginState', function(state) {
console.log(tab(1) + state);
});

tester.on('endTest', function(result) {
if (result.equal) {
console.log(' ' + chalk.green(CHECK) + ' ' + result.state);
console.log(tab(2) + chalk.green(CHECK) + ' ' + result.browser);
passed++;
} else {
console.log(' ' + chalk.red(XMARK + ' ' + result.state));
console.log(tab(2) + chalk.red(XMARK + ' ' + result.browser));
failed++;
}
});
Expand Down
22 changes: 17 additions & 5 deletions lib/tester.js
Expand Up @@ -35,15 +35,26 @@ module.exports = inherit(Runner, {
return this._shooter._afterPlan(plan);
},

_runState: function(plan, state) {
this.emit('beginTest', state);
return this._shooter._runState(plan, state)
_beforeState: function(plan, state) {
this.emit('beginState', state);
return this._shooter._beforeState(plan, state);
},

_afterState: function(plan, state) {
this.emit('endState', state);
return this._shooter._afterState(plan, state);
},

_runStateInBrowser: function(plan, state, browser) {
this.emit('beginTest', browser.name);
return this._shooter._runStateInBrowser(plan, state, browser)
.then(this._compareScreenshots.bind(this));
},

_compareScreenshots: function (captureData) {
var prevPath = this.config.getScreenshotPath(captureData.name,
captureData.state),
captureData.state,
captureData.browser),
_this = this;
return Image.compare(captureData.path, prevPath)
.then(function(isEqual) {
Expand All @@ -52,7 +63,8 @@ module.exports = inherit(Runner, {
state: captureData.state,
equal: isEqual,
previousPath: prevPath,
currentPath: captureData.path
currentPath: captureData.path,
browser: captureData.browser
});
});
},
Expand Down

0 comments on commit 3543786

Please sign in to comment.