nightwatch
Advanced tools
Comparing version 0.5.24 to 0.5.25
@@ -223,3 +223,3 @@ var Runner = require('../lib/runner/run.js'); | ||
beforeGlobal(function() { | ||
beforeGlobal.call(this.test_settings.globals, function() { | ||
Selenium.startServer(self.settings, function(error, child, error_out, exitcode) { | ||
@@ -272,3 +272,3 @@ if (error) { | ||
var afterGlobal = self.test_settings.globals && self.test_settings.globals.after || function(done) {done();}; | ||
afterGlobal(function() { | ||
afterGlobal.call(self.test_settings.globals, function() { | ||
self.globalErrorHandler(err); | ||
@@ -275,0 +275,0 @@ }); |
@@ -10,3 +10,13 @@ module.exports = { | ||
myGlobal: 'test_global' | ||
}, | ||
before : function(cb) { | ||
console.log('GLOBAL BEFORE'); | ||
cb(); | ||
}, | ||
after : function(cb) { | ||
console.log('GLOBAL AFTER'); | ||
cb(); | ||
} | ||
}; |
@@ -38,8 +38,13 @@ var util = require('util'); | ||
HttpRequest.prototype.createOptions = function(options) { | ||
var defaultPathPrefix = options.path && options.path.indexOf(Settings.default_path) === -1 ? | ||
HttpRequest.prototype.setPathPrefix = function(options) { | ||
this.defaultPathPrefix = options.path && options.path.indexOf(Settings.default_path) === -1 ? | ||
Settings.default_path : ''; | ||
return this; | ||
}; | ||
HttpRequest.prototype.createOptions = function(options) { | ||
this.setPathPrefix(options); | ||
var reqOptions = { | ||
path : defaultPathPrefix + (options.path || ''), | ||
path : this.defaultPathPrefix + (options.path || ''), | ||
host : options.host || Settings.selenium_host, | ||
@@ -134,3 +139,2 @@ port : options.selenium_port || Settings.selenium_port, | ||
} | ||
//self.emit('complete', response); | ||
}); | ||
@@ -177,3 +181,2 @@ }); | ||
}; | ||
/////////////////////////////////////////////////////////// | ||
@@ -180,0 +183,0 @@ // Helpers |
@@ -84,3 +84,3 @@ /*! | ||
if (screenshotsEnabled) { | ||
if (!screenshots.path) { | ||
if (typeof screenshots.path == 'undefined') { | ||
throw new Error('Please specify the screenshots.path in nightwatch.json.'); | ||
@@ -91,4 +91,4 @@ } | ||
this.options.screenshots = { | ||
'enabled' : false, | ||
'path' : '' | ||
enabled : false, | ||
path : '' | ||
}; | ||
@@ -107,2 +107,4 @@ } | ||
this.api.options.log_screenshot_data = this.options.log_screenshot_data || | ||
(typeof this.options.log_screenshot_data == 'undefined'); | ||
var seleniumPort = this.options.seleniumPort || this.options.selenium_port; | ||
@@ -109,0 +111,0 @@ var seleniumHost = this.options.seleniumHost || this.options.selenium_host; |
@@ -188,11 +188,2 @@ /** | ||
try { | ||
if (typeof module.desiredCapabilities == 'object') { | ||
opts.desiredCapabilities = opts.desiredCapabilities || {}; | ||
for (var capability in module.desiredCapabilities) { | ||
if (module.desiredCapabilities.hasOwnProperty(capability)) { | ||
opts.desiredCapabilities[capability] = module.desiredCapabilities[capability]; | ||
} | ||
} | ||
} | ||
client = Nightwatch.client(opts); | ||
@@ -560,7 +551,24 @@ } catch (err) { | ||
var testSuiteName = getTestSuiteName(moduleName); | ||
if (opts.output) { | ||
var testSuiteName = '[' + getTestSuiteName(moduleName) + '] Test Suite'; | ||
console.log('\n' + Logger.colors.cyan(testSuiteName, Logger.colors.background.black)); | ||
console.log(Logger.colors.purple(new Array(testSuiteName.length + 1).join('='))); | ||
var testSuiteDisplay = '[' + testSuiteName + '] Test Suite'; | ||
console.log('\n' + Logger.colors.cyan(testSuiteDisplay, Logger.colors.background.black)); | ||
console.log(Logger.colors.purple(new Array(testSuiteDisplay.length + 1).join('='))); | ||
} | ||
opts.desiredCapabilities = opts.desiredCapabilities || {}; | ||
if (opts.sync_test_names || (typeof opts.sync_test_names == 'undefined')) { | ||
// optionally send the local test name (derived from filename) | ||
// to the remote selenium server. useful for test reporting in cloud service providers | ||
opts.desiredCapabilities.name = testSuiteName; | ||
} | ||
if (typeof module.desiredCapabilities == 'object') { | ||
for (var capability in module.desiredCapabilities) { | ||
if (module.desiredCapabilities.hasOwnProperty(capability)) { | ||
opts.desiredCapabilities[capability] = module.desiredCapabilities[capability]; | ||
} | ||
} | ||
} | ||
runModule(module, opts, moduleName, moduleKey, function moduleCallback(err, modulekeys) { | ||
@@ -567,0 +575,0 @@ if (fullpaths.length) { |
@@ -101,4 +101,4 @@ module.exports = function(client) { | ||
var self = this; | ||
return this.screenshot(function(result) { | ||
client.saveScreenshotToFile(fileName, result.value, function() { | ||
return this.screenshot(client.api.options.log_screenshot_data, function(result) { | ||
client.saveScreenshotToFile(fileName, result.screenshot_data, function() { | ||
if (typeof callback === 'function') { | ||
@@ -105,0 +105,0 @@ callback.call(self, result); |
@@ -772,7 +772,17 @@ module.exports = function(Nightwatch) { | ||
* @link /session/:sessionId/screenshot | ||
* @param {boolean} log_screenshot_data Whether or not the screenshot data should appear in the logs when running with --verbose | ||
* @param {function} [callback] Optional callback function to be called when the command finishes. | ||
* @api protocol | ||
*/ | ||
Actions.screenshot = function(callback) { | ||
return getRequest('/screenshot', callback); | ||
Actions.screenshot = function(log_screenshot_data, callback) { | ||
return getRequest('/screenshot', function(result) { | ||
result = result || {}; | ||
result.screenshot_data = result.value; | ||
if (!log_screenshot_data) { | ||
result.value = ''; | ||
} | ||
if (callback) { | ||
callback.call(Nightwatch.api, result); | ||
} | ||
}); | ||
}; | ||
@@ -779,0 +789,0 @@ |
{ | ||
"name": "nightwatch", | ||
"description": "A node.js bindings implementation for selenium 2.0/webdriver", | ||
"version": "0.5.24", | ||
"version": "0.5.25", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Andrei Rusu", |
@@ -15,3 +15,3 @@ { | ||
"url" : "/wd/hub/session", | ||
"postdata" : "{\"desiredCapabilities\":{\"browserName\":\"firefox\",\"javascriptEnabled\":true,\"acceptSslCerts\":true,\"platform\":\"ANY\",\"name\":\"test-Name\"}}", | ||
"postdata" : "", | ||
"response" : "{\"status\": 0, \"sessionId\": \"1352110219202\", \"value\": { \"javascriptEnabled\": true, \"browserName\": \"firefox\", \"version\": \"TEST\", \"platform\": \"TEST\"}, \"state\": null}", | ||
@@ -18,0 +18,0 @@ "responseHeaders" : { |
@@ -10,2 +10,3 @@ var BASE_PATH = process.env.NIGHTWATCH_COV | ||
process.removeAllListeners('exit'); | ||
process.removeAllListeners('uncaughtException'); | ||
callback(); | ||
@@ -12,0 +13,0 @@ }, |
@@ -21,2 +21,4 @@ var MockServer = require('mockserver'); | ||
test.expect(4); | ||
this.client.api.options.log_screenshot_data = false; | ||
this.client.saveScreenshotToFile = function(fileName, data, cb) { | ||
@@ -29,5 +31,7 @@ test.equal(fileName, 'screenshot.png'); | ||
this.client.api.saveScreenshot('screenshot.png', function(result) { | ||
test.equal(result.value, 'screendata'); | ||
test.equal(result.value, ''); | ||
test.equal(result.screenshot_data, 'screendata'); | ||
test.done(); | ||
}); | ||
}, | ||
@@ -40,2 +44,2 @@ | ||
} | ||
} | ||
}; |
@@ -176,3 +176,2 @@ var os = require('os'); | ||
eq(client.api.options.screenshots, false); | ||
test.done(); | ||
@@ -195,2 +194,18 @@ }, | ||
testSetOptionsScreenshots : function(test) { | ||
var client = this.client = Client.init({ | ||
screenshots : { | ||
enabled : true, | ||
path : '' | ||
}, | ||
log_screenshot_data : true | ||
}); | ||
var eq = test.equals; | ||
eq(client.api.options.log_screenshot_data, true); | ||
eq(client.api.options.screenshotsPath, ''); | ||
test.done(); | ||
}, | ||
testSetOptionsScreenshotsThrows : function(test) { | ||
test.throws(function() { | ||
@@ -197,0 +212,0 @@ var client = this.client = Client.init({ |
@@ -10,2 +10,4 @@ var BASE_PATH = process.env.NIGHTWATCH_COV | ||
this.Runner = require('../../../'+ BASE_PATH +'/runner/run.js'); | ||
process.removeAllListeners('exit'); | ||
process.removeAllListeners('uncaughtException'); | ||
cb(); | ||
@@ -207,3 +209,23 @@ }, | ||
}); | ||
}, | ||
testRunModuleSyncName : function(test) { | ||
test.expect(3); | ||
var testsPath = path.join(process.cwd(), '/sampletests/syncnames'); | ||
this.Runner.run([testsPath], { | ||
seleniumPort : 10195, | ||
silent : true, | ||
output : false, | ||
sync_test_names : true, | ||
globals : { | ||
test : test | ||
} | ||
}, { | ||
output_folder : false | ||
}, function(err, results) { | ||
test.equals(err, null); | ||
test.ok('sampleTest' in results.modules); | ||
test.done(); | ||
}); | ||
} | ||
}; |
@@ -515,3 +515,3 @@ var BASE_PATH = process.env.NIGHTWATCH_COV ? 'lib-cov' : 'lib'; | ||
this.client.on('selenium:session_create', function(sessionId) { | ||
var command = protocol.screenshot(function callback() { | ||
var command = protocol.screenshot(false, function callback() { | ||
test.done(); | ||
@@ -518,0 +518,0 @@ }); |
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
368289
139
10759