nightwatch
Advanced tools
Comparing version 0.7.6 to 0.7.7
@@ -61,12 +61,12 @@ var util = require('util'); | ||
ChaiAssertion.addMethod('attribute', function(attribute) { | ||
createAssertion(AttributeAssertion, this, [attribute]); | ||
ChaiAssertion.addMethod('attribute', function(attribute, msg) { | ||
createAssertion(AttributeAssertion, this, [attribute, msg]); | ||
}); | ||
ChaiAssertion.addMethod('css', function(property) { | ||
createAssertion(CssAssertion, this, [property]); | ||
ChaiAssertion.addMethod('css', function(property, msg) { | ||
createAssertion(CssAssertion, this, [property, msg]); | ||
}); | ||
function typeAssertion(type) { | ||
createAssertion(TypeAssertion, this, [type]); | ||
function typeAssertion(type, msg) { | ||
createAssertion(TypeAssertion, this, [type, msg]); | ||
} | ||
@@ -73,0 +73,0 @@ |
@@ -202,3 +202,3 @@ /** | ||
BaseAssertion.prototype.formatMessage = function() { | ||
this.message = Utils.format(this.message, this.selector); | ||
this.message = Utils.format(this.message || this.message, this.selector); | ||
this.message += this.messageParts.join(''); | ||
@@ -263,7 +263,8 @@ }; | ||
} | ||
this.messageParts.push( | ||
verb, | ||
': "', value, '"' | ||
); | ||
if (!this.customMessage) { | ||
this.messageParts.push( | ||
verb, | ||
': "', value, '"' | ||
); | ||
} | ||
}; | ||
@@ -284,3 +285,5 @@ | ||
this.waitForMs = value; | ||
this.messageParts.push(this.checkWaitForMsg(this.waitForMs)); | ||
if (!this.customMessage) { | ||
this.messageParts.push(this.checkWaitForMsg(this.waitForMs)); | ||
} | ||
} | ||
@@ -293,3 +296,5 @@ }; | ||
} | ||
this.messageParts.push(' that '); | ||
if (!this.customMessage) { | ||
this.messageParts.push(' that '); | ||
} | ||
return this; | ||
@@ -302,3 +307,5 @@ }; | ||
} | ||
this.messageParts.push(' which '); | ||
if (!this.customMessage) { | ||
this.messageParts.push(' which '); | ||
} | ||
return this; | ||
@@ -320,2 +327,11 @@ }; | ||
BaseAssertion.prototype.retryCommand = function() { | ||
if (this.elementResult) { | ||
this.onPromiseResolved(); | ||
} else { | ||
this.promise.then(this.onPromiseResolved.bind(this), this.onPromiseRejected.bind(this)); | ||
this.element.locate(); | ||
} | ||
}; | ||
module.exports = BaseAssertion; |
@@ -8,2 +8,3 @@ /** | ||
* browser.expect.element('body').to.not.have.attribute('data-attr'); | ||
* browser.expect.element('body').to.not.have.attribute('data-attr', 'Testing if body does not have data-attr'); | ||
* browser.expect.element('body').to.have.attribute('data-attr').before(100); | ||
@@ -23,2 +24,3 @@ * browser.expect.element('body').to.have.attribute('data-attr') | ||
* @param {string} attribute The attribute name | ||
* @param {string} [message] Optional log message to display in the output. If missing, one is displayed by default. | ||
* @display .attribute(name) | ||
@@ -32,8 +34,10 @@ * @since v0.7 | ||
function AttributeAssertion(attribute) { | ||
function AttributeAssertion(attribute, msg) { | ||
this.flag('attributeFlag', true); | ||
this.attribute = attribute; | ||
this.customMessage = msg; | ||
this.message = msg || 'Expected element <%s> to ' + (this.negate ? 'not have' : 'have') + ' attribute "' + attribute + '"'; | ||
BaseAssertion.call(this); | ||
this.message = 'Expected element <%s> to ' + (this.negate ? 'not have' : 'have') + ' attribute "' + attribute + '"'; | ||
this.start(); | ||
@@ -97,6 +101,2 @@ } | ||
AttributeAssertion.prototype.retryCommand = function() { | ||
this.onPromiseResolved(); | ||
}; | ||
module.exports = AttributeAssertion; |
@@ -7,2 +7,3 @@ /** | ||
* browser.expect.element('#main').to.have.css('display'); | ||
* browser.expect.element('#main').to.have.css('display', 'Testing for display'); | ||
* browser.expect.element('#main').to.not.have.css('display'); | ||
@@ -18,2 +19,3 @@ * browser.expect.element('#main').to.have.css('display').before(100); | ||
* @param {string} property The css property name | ||
* @param {string} [message] Optional log message to display in the output. If missing, one is displayed by default.* | ||
* @display .css(property) | ||
@@ -27,3 +29,3 @@ * @since v0.7 | ||
function CssAssertion(property) { | ||
function CssAssertion(property, msg) { | ||
this.cssProperty = property; | ||
@@ -33,4 +35,4 @@ this.flag('cssFlag', true); | ||
BaseAssertion.call(this); | ||
this.message = 'Expected element <%s> to ' + (this.negate ? 'not have' : 'have') + ' css property "' + property + '"'; | ||
this.customMessage = msg; | ||
this.message = msg || 'Expected element <%s> to ' + (this.negate ? 'not have' : 'have') + ' css property "' + property + '"'; | ||
this.start(); | ||
@@ -71,6 +73,2 @@ } | ||
CssAssertion.prototype.retryCommand = function() { | ||
this.onPromiseResolved(); | ||
}; | ||
module.exports = CssAssertion; |
@@ -55,6 +55,2 @@ /** | ||
EnabledAssertion.prototype.retryCommand = function() { | ||
this.onPromiseResolved(); | ||
}; | ||
module.exports = EnabledAssertion; |
@@ -55,6 +55,2 @@ /** | ||
SelectedAssertion.prototype.retryCommand = function() { | ||
this.onPromiseResolved(); | ||
}; | ||
module.exports = SelectedAssertion; | ||
module.exports = SelectedAssertion; |
@@ -58,6 +58,2 @@ /** | ||
TextAssertion.prototype.retryCommand = function() { | ||
this.onPromiseResolved(); | ||
}; | ||
module.exports = TextAssertion; | ||
module.exports = TextAssertion; |
@@ -7,2 +7,3 @@ /** | ||
* browser.expect.element('#q').to.be.an('input'); | ||
* browser.expect.element('#q').to.be.an('input', 'Testing if #q is an input'); | ||
* browser.expect.element('#w').to.be.a('span'); | ||
@@ -17,2 +18,3 @@ * }; | ||
* @param {string} type The expected type | ||
* @param {string} [message] Optional log message to display in the output. If missing, one is displayed by default. | ||
* @api expect | ||
@@ -24,3 +26,3 @@ */ | ||
function TypeAssertion(type) { | ||
function TypeAssertion(type, msg) { | ||
this.type = type; | ||
@@ -31,3 +33,4 @@ | ||
this.article = ['a', 'e', 'i', 'o'].indexOf(type.substring(0, 1)) > -1 ? 'an' : 'a'; | ||
this.message = 'Expected element <%s> to ' + (this.negate ? 'not be' : 'be') + ' ' + this.article +' ' + type; | ||
this.customMessage = msg; | ||
this.message = msg || 'Expected element <%s> to ' + (this.negate ? 'not be' : 'be') + ' ' + this.article +' ' + type; | ||
this.start(); | ||
@@ -60,6 +63,2 @@ } | ||
TypeAssertion.prototype.retryCommand = function() { | ||
this.onPromiseResolved(); | ||
}; | ||
module.exports = TypeAssertion; | ||
module.exports = TypeAssertion; |
@@ -55,6 +55,2 @@ /** | ||
ValueAssertion.prototype.retryCommand = function() { | ||
this.onPromiseResolved(); | ||
}; | ||
module.exports = ValueAssertion; | ||
module.exports = ValueAssertion; |
@@ -54,6 +54,2 @@ /** | ||
VisibleAssertion.prototype.retryCommand = function() { | ||
this.onPromiseResolved(); | ||
}; | ||
module.exports = VisibleAssertion; | ||
module.exports = VisibleAssertion; |
@@ -700,11 +700,12 @@ var fs = require('fs'); | ||
Utils.processAsyncQueue(workerCount, modulePaths, function(modulePath, index, next) { | ||
var filename = path.basename(modulePath, '.js'); | ||
var outputLabel = Utils.getModuleKey(modulePath, self.settings.src_folders, modulePaths); | ||
var childOutput = self.childProcessOutput[outputLabel] = []; | ||
self.childProcessOutput[filename] = []; | ||
// arguments to the new child process, essentially running a single test suite | ||
var childArgs = args.slice(); | ||
childArgs.push('--test', modulePath, '--test-worker'); | ||
var child = new ChildProcess(filename, index, self.childProcessOutput[filename], self.settings, childArgs); | ||
child.setLabel(Utils.getModuleKey(modulePath, self.settings.src_folders, modulePaths)); | ||
var child = new ChildProcess(outputLabel, index, childOutput, self.settings, childArgs); | ||
child.setLabel(outputLabel); | ||
self.runningProcesses[child.itemKey] = child; | ||
@@ -711,0 +712,0 @@ self.runningProcesses[child.itemKey].run(availColors, function (output, exitCode) { |
var Logger = require('../../util/logger.js'); | ||
module.exports = { | ||
var ErrorHandler = module.exports = { | ||
handle : function(err, results, finished) { | ||
@@ -17,3 +17,3 @@ finished = finished || function() {}; | ||
this.logError(err); | ||
ErrorHandler.logError(err); | ||
@@ -20,0 +20,0 @@ finished(false); |
@@ -8,2 +8,3 @@ var util = require('util'); | ||
events.EventEmitter.call(this); | ||
this.setMaxListeners(0); | ||
} | ||
@@ -10,0 +11,0 @@ |
@@ -119,2 +119,3 @@ var path = require('path'); | ||
}, function onError(error) { | ||
console.log(error.stack) | ||
deferred.reject(error); | ||
@@ -121,0 +122,0 @@ }) |
@@ -368,2 +368,3 @@ var path = require('path'); | ||
} catch (err) { | ||
console.log(err) | ||
deferred.reject(err); | ||
@@ -370,0 +371,0 @@ } |
@@ -7,3 +7,3 @@ var path = require('path'); | ||
function isFileExcluded(file, opts) { | ||
function isFolderExcluded(resource, opts) { | ||
if (!opts.exclude) { | ||
@@ -15,3 +15,11 @@ return false; | ||
return Matchers.exclude.some(function(item) { | ||
return item.indexOf(file) > -1; | ||
if (item.indexOf(resource) === -1) { | ||
return false; | ||
} | ||
try { | ||
return fs.statSync(item).isDirectory(); | ||
} catch (err) { | ||
return false; | ||
} | ||
}); | ||
@@ -45,9 +53,9 @@ } | ||
list.forEach(function(file) { | ||
file = [dir, file].join(path.sep); | ||
list.forEach(function(resource) { | ||
resource = [dir, resource].join(path.sep); | ||
fs.stat(file, function(err, stat) { | ||
fs.stat(resource, function(err, stat) { | ||
if (stat && stat.isDirectory()) { | ||
var dirName = file.split(path.sep).slice(-1)[0]; | ||
var isExcluded = isFileExcluded(file, opts); | ||
var dirName = resource.split(path.sep).slice(-1)[0]; | ||
var isExcluded = isFolderExcluded(resource, opts); // prevent loading of files from an excluded folder | ||
var isSkipped = opts.skipgroup && opts.skipgroup.indexOf(dirName) > -1; | ||
@@ -58,3 +66,3 @@ | ||
} else { | ||
walk(file, function(err, res) { | ||
walk(resource, function(err, res) { | ||
results = results.concat(res); | ||
@@ -68,3 +76,3 @@ pending = pending-1; | ||
} else { | ||
results.push(file); | ||
results.push(resource); | ||
pending = pending-1; | ||
@@ -83,2 +91,4 @@ | ||
readPaths : function (paths, cb, opts) { | ||
Matchers.exclude = []; | ||
Matchers.filter = []; | ||
var extensionPattern = /\.js$/; | ||
@@ -85,0 +95,0 @@ if (paths.length === 1 && extensionPattern.test(paths[0])) { |
{ | ||
"name": "nightwatch", | ||
"description": "A node.js bindings implementation for selenium 2.0/webdriver", | ||
"version": "0.7.6", | ||
"version": "0.7.7", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Andrei Rusu", |
@@ -56,2 +56,27 @@ var Nocks = require('../../nocks.js'); | ||
'to have attribute with message [PASSED]' : function(test) { | ||
Nocks.elementFound().attributeValue('hp vasq'); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.attribute('class', 'Testing if #weblogin has "class"'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.passed, true); | ||
test.equals(expect.assertion.message, 'Testing if #weblogin has "class"'); | ||
test.equals(results.tests[0].message, 'Testing if #weblogin has "class"'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have attribute with message [FAILED]' : function(test) { | ||
Nocks.elementFound().attributeValue(null); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.attribute('class', 'Testing if #weblogin has "class"'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.message, 'Testing if #weblogin has "class" - attribute was not found'); | ||
test.equals(results.tests[0].message, 'Testing if #weblogin has "class" - attribute was not found'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have attribute [FAILED]' : function(test) { | ||
@@ -263,2 +288,41 @@ Nocks.elementFound().attributeValue(null); | ||
'to have attribute equal to with message [PASSED]' : function(test) { | ||
Nocks.elementFound().attributeValue('hp vasq'); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.attribute('class', 'Testing if #weblogin has class which equals hp vasq').equal('hp vasq'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.waitForMs, null); | ||
test.equals(expect.assertion.passed, true); | ||
test.equals(expect.assertion.message, 'Testing if #weblogin has class which equals hp vasq'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have attribute equal with message [FAILED] - attribute not found' : function(test) { | ||
Nocks.elementFound(); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.attribute('class', 'Testing if #weblogin has class which equals hp vasq').equal('hp vasq'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.message, 'Testing if #weblogin has class which equals hp vasq - attribute was not found'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have attribute equal with message [FAILED] - attribute not equal' : function(test) { | ||
Nocks.elementFound().attributeValue('xx'); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.attribute('class', 'Testing if #weblogin has class which equals hp vasq').equal('hp vasq'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.actual, 'xx'); | ||
test.equals(expect.assertion.message, 'Testing if #weblogin has class which equals hp vasq'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have attribute not contains [PASSED]' : function(test) { | ||
@@ -417,2 +481,16 @@ Nocks.elementFound().attributeValue('xx'); | ||
'to have attribute with waitFor - element not found' : function(test) { | ||
this.client.api.globals.waitForConditionPollInterval = 50; | ||
Nocks.elementNotFound(); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.attribute('class').before(60); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equal(expect.assertion.waitForMs, 60); | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.message, 'Expected element <#weblogin> to have attribute "class" in 60ms - element was not found'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have attribute match - throws exception on invalid regex' : function(test) { | ||
@@ -419,0 +497,0 @@ Nocks.elementFound().attributeValue('xx'); |
@@ -63,2 +63,24 @@ var Nocks = require('../../nocks.js'); | ||
'to have css property with message [PASSED]' : function(test) { | ||
Nocks.elementFound().cssProperty('block'); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.css('display', 'Testing if #weblogin has display'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.passed, true); | ||
test.equals(expect.assertion.message, 'Testing if #weblogin has display'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have css property with message [FAILED]' : function(test) { | ||
Nocks.elementFound().cssProperty('', 3); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.css('display', 'Testing if #weblogin has display'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.message, 'Testing if #weblogin has display'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have css property [FAILED]' : function(test) { | ||
@@ -270,2 +292,3 @@ Nocks.elementFound().cssProperty(''); | ||
'to have css property which contains [PASSED]' : function(test) { | ||
@@ -286,3 +309,43 @@ Nocks.elementFound().cssProperty('block'); | ||
}, | ||
'to have css property equal with message [PASSED]' : function(test) { | ||
this.client.api.globals.waitForConditionPollInterval = 200; | ||
Nocks.elementFound().cssProperty('block'); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.css('display', 'Testing if #weblogin has display which equals block').equal('block'); | ||
Nocks.cssProperty('').cssProperty('block'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.actual, 'block'); | ||
test.equals(expect.assertion.passed, true); | ||
test.equals(expect.assertion.message, 'Testing if #weblogin has display which equals block'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have css property equal with message [FAILED] - property not set' : function(test) { | ||
this.client.api.globals.waitForConditionPollInterval = 50; | ||
Nocks.elementFound().cssProperty('', 3); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.css('display', 'Testing if #weblogin has display which equals block').equal('block'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.message, 'Testing if #weblogin has display which equals block'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have css property equal with message [FAILED] - property not equal' : function(test) { | ||
this.client.api.globals.waitForConditionPollInterval = 10; | ||
Nocks.elementFound().cssProperty('xx', 3); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.css('display', 'Testing if #weblogin has display which equals block').equal('block'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.actual, 'xx'); | ||
test.equals(expect.assertion.message, 'Testing if #weblogin has display which equals block'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have css property not contains [PASSED]' : function(test) { | ||
@@ -401,2 +464,16 @@ Nocks.elementFound().cssProperty('xx'); | ||
'to have css property with waitFor - element not found' : function(test) { | ||
this.client.api.globals.waitForConditionPollInterval = 50; | ||
Nocks.elementNotFound(); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.css('display').before(60); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equal(expect.assertion.waitForMs, 60); | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.message, 'Expected element <#weblogin> to have css property "display" in 60ms - element was not found'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have css property match - element not found' : function(test) { | ||
@@ -403,0 +480,0 @@ Nocks.elementNotFound(); |
@@ -153,2 +153,16 @@ var Nocks = require('../../nocks.js'); | ||
'to be enabled with waitFor - element not found' : function(test) { | ||
this.client.api.globals.waitForConditionPollInterval = 50; | ||
Nocks.elementNotFound(); | ||
var expect = this.client.api.expect.element('#weblogin').to.be.enabled.before(60); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equal(expect.assertion.waitForMs, 60); | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.message, 'Expected element <#weblogin> to be enabled in 60ms - element was not found'); | ||
test.done(); | ||
}) | ||
}, | ||
tearDown : function(callback) { | ||
@@ -155,0 +169,0 @@ this.client = null; |
@@ -153,2 +153,16 @@ var Nocks = require('../../nocks.js'); | ||
'to be selected with waitFor - element not found' : function(test) { | ||
this.client.api.globals.waitForConditionPollInterval = 50; | ||
Nocks.elementNotFound(); | ||
var expect = this.client.api.expect.element('#weblogin').to.be.selected.before(60); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equal(expect.assertion.waitForMs, 60); | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.message, 'Expected element <#weblogin> to be selected in 60ms - element was not found'); | ||
test.done(); | ||
}) | ||
}, | ||
tearDown : function(callback) { | ||
@@ -155,0 +169,0 @@ this.client = null; |
@@ -288,2 +288,16 @@ var Nocks = require('../../nocks.js'); | ||
'text to match with waitFor - element not found' : function(test) { | ||
this.client.api.globals.waitForConditionPollInterval = 50; | ||
Nocks.elementNotFound(); | ||
var expect = this.client.api.expect.element('#weblogin').text.to.match(/vasq$/).before(60); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equal(expect.assertion.waitForMs, 60); | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.message, 'Expected element <#weblogin> text to match: "/vasq$/" in 60ms - element was not found'); | ||
test.done(); | ||
}) | ||
}, | ||
'text to match - throws exception on invalid regex' : function(test) { | ||
@@ -290,0 +304,0 @@ Nocks.elementFound().text('xx'); |
@@ -137,2 +137,81 @@ var Nocks = require('../../nocks.js'); | ||
'to be with message [PASSED]' : function(test) { | ||
Nocks.elementFound().name('input'); | ||
var expect = this.client.api.expect.element('#weblogin').to.be.an('input', 'weblogin should be an input'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.selector, '#weblogin'); | ||
test.equals(expect.assertion.negate, false); | ||
test.equals(expect.assertion.waitForMs, null); | ||
test.equals(expect.assertion.passed, true); | ||
test.equals(expect.assertion.article, 'an'); | ||
test.equals(expect.assertion.resultValue, 'input'); | ||
test.equals(expect.assertion.message, 'weblogin should be an input'); | ||
test.deepEqual(expect.assertion.elementResult, { ELEMENT: '0' }); | ||
test.deepEqual(expect.assertion.messageParts, []); | ||
test.equals(results.passed, 1); | ||
test.equals(results.failed, 0); | ||
test.equals(results.tests[0].message, 'weblogin should be an input'); | ||
test.done(); | ||
}) | ||
}, | ||
'to be with message [FAILED]' : function(test) { | ||
Nocks.elementFound().name('div'); | ||
var expect = this.client.api.expect.element('#weblogin').to.be.an('input', 'weblogin should be an input'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.selector, '#weblogin'); | ||
test.equals(expect.assertion.negate, false); | ||
test.equals(expect.assertion.waitForMs, null); | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.expected, 'be an input'); | ||
test.equals(expect.assertion.actual, 'div'); | ||
test.equals(expect.assertion.article, 'an'); | ||
test.equals(expect.assertion.resultValue, 'div'); | ||
test.equals(expect.assertion.message, 'weblogin should be an input'); | ||
test.deepEqual(expect.assertion.elementResult, { ELEMENT: '0' }); | ||
test.deepEqual(expect.assertion.messageParts, []); | ||
test.equals(results.passed, 0); | ||
test.equals(results.failed, 1); | ||
test.equals(results.tests[0].message, 'weblogin should be an input'); | ||
test.done(); | ||
}) | ||
}, | ||
'to be with message - element not found' : function(test) { | ||
Nocks.elementNotFound(); | ||
var expect = this.client.api.expect.element('#weblogin').to.be.an('input', 'weblogin should be an input'); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equals(expect.assertion.selector, '#weblogin'); | ||
test.equals(expect.assertion.negate, false); | ||
test.equals(expect.assertion.waitForMs, null); | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.expected, 'present'); | ||
test.equals(expect.assertion.actual, 'not present'); | ||
test.equals(expect.assertion.resultValue, null); | ||
test.equals(expect.assertion.message, 'weblogin should be an input - element was not found'); | ||
test.deepEqual(expect.assertion.messageParts, [' - element was not found']); | ||
test.equals(results.passed, 0); | ||
test.equals(results.failed, 1); | ||
test.equals(results.tests[0].message, 'weblogin should be an input - element was not found'); | ||
test.done(); | ||
}) | ||
}, | ||
'to be with waitFor - element not found' : function(test) { | ||
this.client.api.globals.waitForConditionPollInterval = 50; | ||
Nocks.elementNotFound(); | ||
var expect = this.client.api.expect.element('#weblogin').to.be.an('input').before(60); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equal(expect.assertion.waitForMs, 60); | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.message, 'Expected element <#weblogin> to be an input in 60ms - element was not found'); | ||
test.done(); | ||
}) | ||
}, | ||
tearDown : function(callback) { | ||
@@ -139,0 +218,0 @@ this.client = null; |
@@ -316,2 +316,16 @@ var Nocks = require('../../nocks.js'); | ||
'to have value equal to with waitFor - element not found' : function(test) { | ||
this.client.api.globals.waitForConditionPollInterval = 50; | ||
Nocks.elementNotFound(); | ||
var expect = this.client.api.expect.element('#weblogin').to.have.value.equal('hp vasq').before(60); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equal(expect.assertion.waitForMs, 60); | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.message, 'Expected element <#weblogin> to have value equal to: "hp vasq" in 60ms - element was not found'); | ||
test.done(); | ||
}) | ||
}, | ||
'to have value match - throws exception on invalid regex' : function(test) { | ||
@@ -318,0 +332,0 @@ Nocks.elementFound().value('xx'); |
@@ -153,2 +153,16 @@ var Nocks = require('../../nocks.js'); | ||
'to be visible with waitFor - element not found' : function(test) { | ||
this.client.api.globals.waitForConditionPollInterval = 50; | ||
Nocks.elementNotFound(); | ||
var expect = this.client.api.expect.element('#weblogin').to.be.visible.before(60); | ||
this.client.on('nightwatch:finished', function(results, errors) { | ||
test.equal(expect.assertion.waitForMs, 60); | ||
test.equals(expect.assertion.passed, false); | ||
test.equals(expect.assertion.message, 'Expected element <#weblogin> to be visible in 60ms - element was not found'); | ||
test.done(); | ||
}) | ||
}, | ||
tearDown : function(callback) { | ||
@@ -155,0 +169,0 @@ this.client = null; |
@@ -5,2 +5,3 @@ var BASE_PATH = process.env.NIGHTWATCH_COV ? 'lib-cov' : 'lib'; | ||
var mockery = require('mockery'); | ||
var path = require('path'); | ||
@@ -116,7 +117,7 @@ module.exports = { | ||
runner.setup({}, function() { | ||
test.equals(self.allArgs.length, 17); | ||
test.ok('sample_1' in runner.runningProcesses); | ||
test.ok('sampleSingleTest_2' in runner.runningProcesses); | ||
test.equals(self.allArgs.length, 18); | ||
test.ok(path.join('sampletests', 'async', 'sample_1') in runner.runningProcesses); | ||
test.ok(path.join('sampletests', 'before-after', 'sampleSingleTest_2') in runner.runningProcesses); | ||
var child = runner.runningProcesses.sample_1; | ||
var child = runner.runningProcesses[path.join('sampletests', 'async', 'sample_1')]; | ||
test.deepEqual(child.env_output, []); | ||
@@ -126,3 +127,3 @@ test.ok(child.mainModule.length > 0); | ||
test.equal(child.startDelay, 10); | ||
test.equal(child.environment, 'sample'); | ||
test.equal(child.environment, path.join('sampletests', 'async', 'sample')); | ||
test.deepEqual(child.settings, runner.settings); | ||
@@ -149,3 +150,3 @@ test.strictEqual(child.globalExitCode, 0); | ||
test.ok(!runner.isParallelMode()); | ||
test.equals(self.allArgs.length, 17); | ||
test.equals(self.allArgs.length, 18); | ||
test.done(); | ||
@@ -175,3 +176,3 @@ }); | ||
test.ok(!runner.isParallelMode()); | ||
test.equals(self.allArgs.length, 17); | ||
test.equals(self.allArgs.length, 18); | ||
test.done(); | ||
@@ -178,0 +179,0 @@ }); |
@@ -215,2 +215,3 @@ var BASE_PATH = process.env.NIGHTWATCH_COV ? 'lib-cov' : 'lib'; | ||
test.ok(!('excluded-module' in results.modules)); | ||
test.ok(!('not-excluded' in results.modules)); | ||
test.done(); | ||
@@ -240,2 +241,24 @@ }); | ||
testRunWithExcludeFile : function(test) { | ||
var testsPath = path.join(process.cwd(), '/sampletests/withexclude'); | ||
var testPattern = path.join('excluded', 'excluded-module.js'); | ||
this.Runner.run([testsPath], { | ||
seleniumPort : 10195, | ||
silent : true, | ||
output : false, | ||
globals : { | ||
test : test | ||
}, | ||
exclude : [testPattern] | ||
}, { | ||
output_folder : false, | ||
start_session : true | ||
}, function(err, results) { | ||
test.ok(!('excluded-module' in results.modules)); | ||
test.ok('not-excluded' in results.modules); | ||
test.done(); | ||
}); | ||
}, | ||
testRunAsync : function(test) { | ||
@@ -449,3 +472,4 @@ test.expect(5); | ||
}, { | ||
output_folder : false | ||
output_folder : false, | ||
start_session : true | ||
}, function(err, results) { | ||
@@ -452,0 +476,0 @@ test.equals(err, null); |
Sorry, the diff of this file is not supported yet
661966
217
18193