Skip to content

Commit

Permalink
Merge changes from v0.3-refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Mar 20, 2014
2 parents 71d4a91 + 5997941 commit 48ff1f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
23 changes: 13 additions & 10 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,11 @@ module.exports = new (function() {
}

// backwards compatibility
var AssertionInstance = function (abortOnFailure, client) {
this.abortOnFailure = abortOnFailure;
this.client = client;
this.api = client.api;
};
util.inherits(AssertionInstance, events.EventEmitter);
AssertionInstance.prototype.command = assertionFn;
var module = loadCommandModule(assertionFn, client.api, {
abortOnFailure : abortOnFailure
});

assertion = new AssertionInstance(abortOnFailure, client);
addCommand(commandName, assertion.command, assertion, parent);
addCommand(commandName, module.command, module.context, parent);
return assertion;
}

Expand Down Expand Up @@ -190,14 +185,22 @@ module.exports = new (function() {
* @param {object} context
* @returns {{command: function, context: *}}
*/
function loadCommandModule(module, context) {
function loadCommandModule(module, context, addt_props) {
var m = {command: null, context: context};

function F() {
if (typeof module === 'object') {
events.EventEmitter.call(this);
}
if (addt_props) {
for (var prop in addt_props) {
if (addt_props.hasOwnProperty(prop)) {
this[prop] = addt_props[prop];
}
}
}
this.client = client;
this.api = client.api;
if (typeof module === 'function') {
module.call(this);
}
Expand Down
7 changes: 6 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,13 @@ Nightwatch.prototype.start = function() {
this.queue.reset();
this.queue.run(function(error) {
if (error) {
var stackTrace = '';
if (error.stack) {
stackTrace = '\n' + error.stack.split('\n').slice(1).join('\n');
}

self.results.errors++;
self.errors.push(error.name + ': ' + error.message);
self.errors.push(error.name + ': ' + error.message + stackTrace);
self.terminate();
return;
}
Expand Down

0 comments on commit 48ff1f6

Please sign in to comment.