-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
74 lines (67 loc) · 2.83 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* Created by nikulkarni on 5/20/15.
*/
'use strict';
var EyesSelenium = require('eyes.selenium');
var Eyes = EyesSelenium.Eyes;
var LogHandler = EyesSelenium.ConsoleLogHandler;
module.exports = {
"setup": function (config, nemo, callback) {
if (config.mock && config.mock === "true") {
var emptyPromise = function (val) {
return function () {
return nemo.driver.controlFlow().execute(function () {
return nemo.wd.promise.fulfilled(val || 'fulfilled');
});
}
};
nemo.eyes = {
open: emptyPromise(),
setBatch: function () {},
close: emptyPromise({isPassed: true, url: 'Eyes in mock mode.. No URL'}),
checkWindow: emptyPromise()
};
return callback(null);
}
var eyes = nemo.eyes = new Eyes();
if (!config.sdk && config.sdk.setApiKey) {
return callback(new Error('nemo-eyes: apiKey is required'));
}
Object.keys(config.sdk).forEach(function (key) {
if (!nemo.eyes[key]) {
return;
}
if (config.sdk[key].constructor !== Array) {
return nemo.eyes[key](config.sdk[key]);
}
nemo.eyes[key].apply(config.sdk[key]);
});
if (config.log && config.log === "true" || config.log === true) {
nemo.eyes.setLogHandler(new LogHandler(true));
}
var viewPort = {
'width': (config.viewport && config.viewport.width) ? config.viewport.width : 1024,
'height': (config.viewport && config.viewport.height) ? config.viewport.height : 768,
};
/**
* A wrapper function for {@code eyes.open} to allow parameters to be set in {@code nemo.data}.
* @param {string} appName The name of the application under test.
* @param {string} testName The test's name.
* @returns {Promise} A promise which resolves when open is done.
*/
nemo.eyes.open = function (appName, testName) {
//return this.constructor.prototype.open.call(this, nemo.driver, appName, testName,
return this.constructor.prototype.open.call(this, nemo.driver, appName, testName,
viewPort);
};
/**
* A wrapper function for {@code eyes.close} to avoid throwing an exception on test failure by default.
* @param {boolean} [shouldThrowEx=false] Whether or not close should throw an exception if the test fails.
* @returns {Promise} A promise which resolves to the test's results.
*/
nemo.eyes.close = function (shouldThrowEx) {
return this.constructor.prototype.close.call(this, !!shouldThrowEx);
};
callback(null);
}
};