testarmada-magellan-nightwatch
Advanced tools
Comparing version 1.4.24 to 1.5.0
var _ = require("lodash"), | ||
methodmissing = require("methodmissing"), | ||
whitelist = require("./whitelist"), | ||
magellanErrorListener = require("./magellan-error-listener"), | ||
@@ -32,18 +31,6 @@ clc = require("cli-color"), | ||
// `proxyObject` is returned as a proxied version of `client` | ||
// (the asynchronous command chain used in Magellan commands) | ||
// | ||
// Behind the scenes, Nightwatch is used to implement most of | ||
// the commands. To reduce how many commands we need to write | ||
// from scratch, the Magellan API is expressed as a whitelist | ||
// to a set of Nightwatch commands. | ||
// (the asynchronous command chain used in Nightwatch.js commands) | ||
// The proxy is implement with methodmissing which intercepts | ||
// all function calls sent to the `proxyObject` and checks if | ||
// they're either in the assertion or command whitelists. | ||
var proxyObject = { | ||
assert: methodmissing({}, function(key, arg) { | ||
if (!_.contains(whitelist.assertions, key)) { | ||
throw new Error("Assertion assert.'" + key + "' is not allowed or doesn't exist"); | ||
} | ||
return getProxiedClient(client.assert[key].apply(client.api, arg), context, steps); | ||
@@ -54,11 +41,7 @@ }) | ||
return methodmissing(proxyObject, function (key, arg) { | ||
if (!_.contains(whitelist.commands, key)) { | ||
throw new Error("Command '" + key + "' is not allowed or doesn't exist"); | ||
} | ||
var chain = client; | ||
// Before any command in this whitelist, we harvest errors and inject our error listener | ||
var injectionWhitelist = ["clickEl", "getEl", "moveToEl"]; | ||
if (_.contains(injectionWhitelist, key)) { | ||
var errorDetectInjectionList = ["clickEl", "getEl", "moveToEl"]; | ||
if (_.contains(errorDetectInjectionList, key)) { | ||
chain = gatherBrowserErrors(client, context, steps); | ||
@@ -68,3 +51,5 @@ } | ||
// We don't have many opportunities to get the session id, especially in a test case | ||
// that's destined to fail, so we attempt to get it here also. | ||
// that's destined to fail, so we attempt to get it here also. The Selenium session id | ||
// is useful for linking to things that are tied to the identity of an individual test | ||
// run, such as saucelabs video URLs, reports, logs, etc. | ||
chain = getSessionId(client); | ||
@@ -71,0 +56,0 @@ |
{ | ||
"name": "testarmada-magellan-nightwatch", | ||
"version": "1.4.24", | ||
"version": "1.5.0", | ||
"description": "Nightwatch.js adapter for Magellan", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -42,5 +42,5 @@ # magellan-nightwatch | ||
### Command Equivalent List | ||
### Enhanced Command List | ||
If you're familiar with Nightwatch or are looking to translate Nightwatch examples into `magellan-nightwatch`, refer to the table below for equivalent support commands: | ||
If you're familiar with Nightwatch or are looking to translate Nightwatch examples into `magellan-nightwatch`, refer to the table below for equivalent enhanced (i.e. more reliable) versions of Nightwatch commands: | ||
@@ -47,0 +47,0 @@ <table> |
162228
1483