nightwatch
Advanced tools
Comparing version 0.5.6 to 0.5.7
var Runner = require('../lib/runner/run.js'); | ||
var Logger = require('../lib/util/logger.js'); | ||
var Selenium = require('../lib/runner/selenium.js'); | ||
var util = require('util'); | ||
var fs = require('fs'); | ||
@@ -129,3 +128,6 @@ var path = require('path'); | ||
setOutputFolder : function() { | ||
this.output_folder = this.cli.command('output').isDefault(this.argv.o) && this.settings.output_folder || this.argv.o; | ||
var isDisabled = this.settings.output_folder === false; | ||
var isDefault = this.cli.command('output').isDefault(this.argv.o); | ||
this.output_folder = isDisabled ? false : (isDefault && this.settings.output_folder || this.argv.o); | ||
return this; | ||
@@ -132,0 +134,0 @@ }, |
/** | ||
* Module dependencies | ||
*/ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Logger = require('../lib/util/logger.js'); | ||
@@ -7,0 +5,0 @@ var cli = require('./_cli.js'); |
@@ -6,2 +6,3 @@ /** | ||
*/ | ||
/* global window */ | ||
@@ -8,0 +9,0 @@ module.exports.command = function(callback) { |
@@ -23,7 +23,8 @@ /** | ||
'digg facebook login' : function (client) { | ||
var fbcredentials; | ||
try { | ||
var fbcredentials = require('./fbcredentials.json'); | ||
fbcredentials = require('./fbcredentials.json'); | ||
} catch (err) { | ||
console.error('Couldn\'t load the facebook credentials file. Please ensure that ' + | ||
'you have the fbcredentials.json in the same folder as the test.') | ||
'you have the fbcredentials.json in the same folder as the test.'); | ||
process.exit(); | ||
@@ -53,2 +54,2 @@ } | ||
} | ||
} | ||
}; |
module.exports = { | ||
'Demo test GitHub' : function (client) { | ||
client | ||
.url("https://github.com/beatfactor/nightwatch") | ||
.url('https://github.com/beatfactor/nightwatch') | ||
.waitForElementVisible('body', 1000) | ||
@@ -11,2 +11,2 @@ .assert.title('beatfactor/nightwatch · GitHub') | ||
} | ||
} | ||
}; |
@@ -83,5 +83,6 @@ /*! | ||
* | ||
* @param {string} commandName | ||
* @param {function} assertionFn | ||
* @param {boolean} abortOnFailure | ||
* @param {object} client | ||
* @param {object} parent | ||
* @returns {AssertionInstance} | ||
@@ -282,2 +283,3 @@ */ | ||
* @param {Object} [parent] | ||
* @param {Boolean} [resetQueue] | ||
*/ | ||
@@ -294,3 +296,3 @@ function addCommand(name, command, context, parent, resetQueue) { | ||
var args = Array.prototype.slice.call(arguments); | ||
CommandQueue.add(name, command, context, args, resetQueue); | ||
CommandQueue.add(name, command, context, args); | ||
return client.api; // for chaining | ||
@@ -297,0 +299,0 @@ }; |
@@ -87,3 +87,3 @@ var util = require('util'); | ||
var expected = typeof self.expected == 'function' && self.expected() || self.expected; | ||
var expected = typeof self.expected == 'function' ? self.expected() : self.expected; | ||
self.client.assertion(passed, value, expected, self.message, self.abortOnFailure); | ||
@@ -90,0 +90,0 @@ }); |
@@ -18,3 +18,3 @@ var util = require('util'); | ||
AsyncTree.prototype.append = function(nodeName, command, context, args, reset) { | ||
AsyncTree.prototype.append = function(nodeName, command, context, args) { | ||
var node = { | ||
@@ -29,7 +29,7 @@ startTime : null, | ||
children : [], | ||
parent : this.currentNode, | ||
reset : reset || false | ||
parent : this.currentNode | ||
}; | ||
this.currentNode.children.push(node); | ||
if (this.currentNode.started && !this.currentNode.done && !this.currentNode.reset) { | ||
if (this.currentNode.started && !this.currentNode.done) { | ||
this.scheduleTraverse(); | ||
@@ -39,24 +39,33 @@ } | ||
AsyncTree.prototype.runChildNode = function runChildNode(node) { | ||
var self = this; | ||
this.runCommand(node, function onCommandComplete(command) { | ||
var timems = new Date().getTime() - node.startTime; | ||
Logger.log(' ' + Logger.colors.green('→') + | ||
' Completed command ' + Logger.colors.light_green(node.name), '(' + timems, 'ms)'); | ||
// checking if new children have been added while running this command which haven't finished yet | ||
var childrenInProgress = false; | ||
var currentChildNode = null; | ||
for (var i = 0; i < node.children.length; i++) { | ||
currentChildNode = node.children[i]; | ||
if (!currentChildNode.done && !currentChildNode.started) { | ||
childrenInProgress = true; | ||
break; | ||
} | ||
} | ||
if (!childrenInProgress) { | ||
self.traverse(); | ||
} | ||
}); | ||
}; | ||
AsyncTree.prototype.walkDown = function walkDown(context) { | ||
var self = this; | ||
var node = this.getNextChild(context); | ||
if (node) { | ||
this.currentNode = node; | ||
this.runCommand(node, function onCommandComplete(command) { | ||
var timems = new Date().getTime() - node.startTime; | ||
Logger.log(' ' + Logger.colors.green('→') + | ||
' Completed command ' + Logger.colors.light_green(node.name), '(' + timems, 'ms)'); | ||
// checking if new children have been added while running this command which haven't finished yet | ||
var childrenInProgress = false; | ||
for (var i = 0; i < node.children.length; i++) { | ||
if (!node.children[i].done) { | ||
childrenInProgress = true; | ||
} | ||
} | ||
if (!childrenInProgress) { | ||
self.traverse(); | ||
} | ||
}); | ||
this.runChildNode(node); | ||
} else { | ||
@@ -88,3 +97,5 @@ context.done = true; | ||
AsyncTree.prototype.runCommand = function(node, callback) { | ||
this.currentNode = node; | ||
node.started = true; | ||
try { | ||
@@ -103,6 +114,5 @@ var commandFn = node.command; | ||
var emitter = commandFn.apply(node.context, node.args); | ||
if (emitter instanceof events.EventEmitter) { | ||
emitter.once('complete', callback); | ||
} else if (this.currentNode.reset) { | ||
this.traverse(); | ||
} | ||
@@ -137,3 +147,3 @@ return node.context; | ||
if (this.scheduled) { | ||
return; | ||
return this; | ||
} | ||
@@ -143,4 +153,4 @@ this.scheduled = true; | ||
process.nextTick(function() { | ||
self.scheduled = false; | ||
self.traverse(); | ||
self.scheduled = false; | ||
}); | ||
@@ -147,0 +157,0 @@ }; |
var util = require('util'), | ||
events = require('events'), | ||
qs = require('querystring'), | ||
http = require('http'), | ||
@@ -5,0 +4,0 @@ https = require('https'), |
var fs = require('fs'), | ||
path = require('path'), | ||
ejs = require('ejs'), | ||
child_process = require('child_process'); | ||
ejs = require('ejs'); | ||
@@ -6,0 +5,0 @@ exports.save = function(results, opts, callback) { |
@@ -6,3 +6,2 @@ /** | ||
var fs = require('fs'); | ||
var util = require('util'); | ||
var mkpath = require('mkpath'); | ||
@@ -9,0 +8,0 @@ var minimatch = require('minimatch'); |
{ | ||
"name": "nightwatch", | ||
"description": "A node.js bindings implementation for selenium 2.0/webdriver", | ||
"version": "0.5.6", | ||
"version": "0.5.7", | ||
"author": { | ||
@@ -21,2 +21,3 @@ "name": "Andrei Rusu", | ||
"dependencies": { | ||
"grunt": "~0.4.4", | ||
"ejs": ">=0.8.3", | ||
@@ -33,3 +34,8 @@ "optimist": ">=0.3.5", | ||
"mock-spawn": "^0.2.1", | ||
"mockery": "^1.4.0" | ||
"mockery": "~1.4.0", | ||
"jsonlint": "~1.6.0", | ||
"grunt-contrib-jshint": "~0.10.0", | ||
"grunt-jsonlint": "~1.0.4", | ||
"grunt-complexity": "^0.1.7", | ||
"grunt-npm-release": "latest" | ||
}, | ||
@@ -42,5 +48,5 @@ "bin": { | ||
"jshint": "./node_modules/.bin/jshint --verbose --config .jshintrc lib/", | ||
"coveralls": "jscoverage lib --exclude *.ejs,*.json && NIGHTWATCH_COV=1 node ./tests/run_tests.js lcov | coveralls", | ||
"coverage": "jscoverage lib --exclude *.ejs,*.json && NIGHTWATCH_COV=1 node ./tests/run_tests.js lcov > ./lib-cov/lcov.info", | ||
"test": "node ./tests/run_tests.js" | ||
} | ||
} |
@@ -33,2 +33,12 @@ var BASE_PATH = process.env.NIGHTWATCH_COV | ||
mockery.registerMock('./nightwatch.json', config); | ||
mockery.registerMock('./output_disabled.json', { | ||
src_folders : ['tests'], | ||
output_folder : false, | ||
test_settings : { | ||
'default' : { | ||
silent : true | ||
} | ||
} | ||
}); | ||
mockery.registerMock('./empty.json', { | ||
@@ -95,2 +105,5 @@ src_folders : 'tests' | ||
} | ||
if (b == './output_disabled.json') { | ||
return './output_disabled.json'; | ||
} | ||
if (b == './empty.json') { | ||
@@ -157,2 +170,24 @@ return './empty.json'; | ||
testSetOutputFolder : function(test) { | ||
mockery.registerMock('fs', { | ||
existsSync : function(module) { | ||
if (module == './settings.json') { | ||
return false; | ||
} | ||
return true; | ||
} | ||
}); | ||
var CliRunner = require('../../../'+ BASE_PATH +'/../bin/_clirunner.js'); | ||
var runner = new CliRunner({ | ||
c : './output_disabled.json', | ||
e : 'default' | ||
}).init(); | ||
test.equals(runner.output_folder, false); | ||
test.done(); | ||
}, | ||
testReadSettingsDeprecated : function(test) { | ||
@@ -394,3 +429,3 @@ mockery.registerMock('../lib/util/logger.js', { | ||
test.expect(2); | ||
runner.globalErrorHandler = function(err) { | ||
@@ -397,0 +432,0 @@ test.equals(err.message, 'Server already running.'); |
@@ -1,4 +0,2 @@ | ||
var BASE_PATH = process.env.NIGHTWATCH_COV | ||
? 'lib-cov' | ||
: 'lib'; | ||
var BASE_PATH = process.env.NIGHTWATCH_COV ? 'lib-cov' : 'lib'; | ||
@@ -55,3 +53,3 @@ var Api = require('../../' + BASE_PATH + '/core/api.js'); | ||
var queue = client.enqueueCommand('customCommandConstructor', []); | ||
var command = queue.currentNode.children[0]; | ||
var command = queue.currentNode; | ||
test.equal(command.name, 'customCommandConstructor'); | ||
@@ -58,0 +56,0 @@ test.equal(command.context, client.api, 'Command should contain a reference to main client instance.'); |
@@ -127,3 +127,5 @@ var Client = require('../nightwatch.js'); | ||
tearDown : function(callback) { | ||
this.client && this.client.queue.reset(); | ||
if (this.client) { | ||
this.client.queue.reset(); | ||
} | ||
this.client = null; | ||
@@ -130,0 +132,0 @@ // clean up |
@@ -1,4 +0,2 @@ | ||
var BASE_PATH = process.env.NIGHTWATCH_COV | ||
? 'lib-cov' | ||
: 'lib'; | ||
var BASE_PATH = process.env.NIGHTWATCH_COV ? 'lib-cov' : 'lib'; | ||
@@ -890,3 +888,3 @@ module.exports = { | ||
test.equal(command.request.method, "POST"); | ||
test.equal(command.request.method, 'POST'); | ||
test.equal(command.data, '{"url":"http://localhost"}'); | ||
@@ -896,3 +894,3 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/url'); | ||
test.done(); | ||
}) | ||
}); | ||
}); | ||
@@ -907,3 +905,3 @@ }, | ||
test.equal(command.request.method, "GET"); | ||
test.equal(command.request.method, 'GET'); | ||
test.equal(command.request.path, '/wd/hub/session/1352110219202/url'); | ||
@@ -910,0 +908,0 @@ command.on('result', function() { |
@@ -1,4 +0,2 @@ | ||
var BASE_PATH = process.env.NIGHTWATCH_COV | ||
? 'lib-cov' | ||
: 'lib'; | ||
var BASE_PATH = process.env.NIGHTWATCH_COV ? 'lib-cov' : 'lib'; | ||
@@ -5,0 +3,0 @@ var CommandQueue = require('../../' + BASE_PATH +'/core/queue.js'); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9792707
129
9752
5
11
117
+ Addedgrunt@~0.4.4
+ Addedabbrev@1.1.1(transitive)
+ Addedargparse@0.1.16(transitive)
+ Addedasync@0.1.22(transitive)
+ Addedcoffee-script@1.3.3(transitive)
+ Addedcolors@0.6.2(transitive)
+ Addeddateformat@1.0.2-1.2.3(transitive)
+ Addedesprima@1.0.4(transitive)
+ Addedeventemitter2@0.4.14(transitive)
+ Addedexit@0.1.2(transitive)
+ Addedfindup-sync@0.1.3(transitive)
+ Addedgetobject@0.1.0(transitive)
+ Addedglob@3.1.213.2.11(transitive)
+ Addedgraceful-fs@1.2.3(transitive)
+ Addedgrunt@0.4.5(transitive)
+ Addedgrunt-legacy-log@0.1.3(transitive)
+ Addedgrunt-legacy-log-utils@0.1.1(transitive)
+ Addedgrunt-legacy-util@0.2.0(transitive)
+ Addedhooker@0.2.3(transitive)
+ Addediconv-lite@0.2.11(transitive)
+ Addedinherits@1.0.22.0.4(transitive)
+ Addedjs-yaml@2.0.5(transitive)
+ Addedlodash@0.9.22.4.2(transitive)
+ Addedminimatch@0.3.0(transitive)
+ Addednopt@1.0.10(transitive)
+ Addedrimraf@2.2.8(transitive)
+ Addedunderscore@1.7.0(transitive)
+ Addedunderscore.string@2.2.12.3.32.4.0(transitive)
+ Addedwhich@1.0.9(transitive)