forked from LHNCBC/formbuilder-lhcforms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotractor.conf.js
149 lines (130 loc) · 4.95 KB
/
protractor.conf.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// Protractor configuration
// https://github.com/angular/protractor/blob/master/referenceConf.js
'use strict';
var FirefoxProfile = require('firefox-profile');
var q = require('q');
var envConfig;
try {
envConfig = require('./formbuilder.conf');
} catch(e) {
envConfig = {};
}
var prot = envConfig.https ? 'https' : 'http';
var baseUrl = prot + '://localhost:' + envConfig.port;
function getMultiCapabilities() {
"use strict";
var deferred = q.defer();
var firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.download.folderList", 2);
firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);
firefoxProfile.setPreference("browser.download.dir", '/tmp');
firefoxProfile.setPreference("browser.download.useDownloadDir", true);
firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/json");
firefoxProfile.setPreference("network.http.phishy-userpass-length", 255);
firefoxProfile.setPreference("network.automatic-ntlm-auth.trusted-uris", "localhost");
firefoxProfile.encoded(function(encodedProfile) {
var multiCapabilities = [/*{
browserName: 'firefox',
firefox_profile : encodedProfile
},*/{
browserName: 'chrome',
chromeOptions: {
prefs: {
download: {
'prompt_for_download': false,
'directory_upgrade': true,
'default_directory': '/tmp'
}
},
args: ['disable-infobars', 'allow-insecure-localhost', 'window-size=1600,1400']
}
}];
deferred.resolve(multiCapabilities);
});
return deferred.promise;
}
exports.config = {
// The timeout for each script run on the browser. This should be longer
// than the maximum time your application needs to stabilize between tasks.
allScriptsTimeout: 110000,
// A base URL for your application under test. Calls to protractor.get()
// with relative paths will be prepended with this.
baseUrl: baseUrl,
// If true, only chromedriver or firefox driver will be started, not a standalone selenium.
// Tests for browsers other than chrome and firefox will not run.
directConnect: true,
// list of files / patterns to load in the browser
specs: [
'test/e2e/**/*.spec.js'
],
// Patterns to exclude.
exclude: [],
// ----- Capabilities to be passed to the webdriver instance ----
//
// For a full list of available capabilities, see
// https://code.google.com/p/selenium/wiki/DesiredCapabilities
// and
// https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js
//capabilities: {'browserName': 'chrome'},
// Fix the port number so we can restrict access to it via iptables
seleniumPort: 4444,
getMultiCapabilities: getMultiCapabilities,
// ----- The test framework -----
//
// Jasmine and Cucumber are fully supported as a test and assertion framework.
// Mocha has limited beta support. You will need to include your own
// assertion framework if working with mocha.
framework: 'jasmine2',
// ----- Options to be passed to minijasminenode -----
//
// See the full list at https://github.com/juliemr/minijasminenode
jasmineNodeOpts: {
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare: function(){
/**
* By default, protracotor expects it to be angular application. This is used
* to switch between angular and non angular sites.
*
* @param {Boolean} flag
* @returns {void}
*/
global.setAngularSite = function(flag){
browser.ignoreSynchronization = !flag;
};
// Replace default dot reporter with something better.
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
// add jasmine spec reporter
jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}));
// Copied from lforms project to disable animation for testing. -Ajay 04/20/2017
// disable animation
// http://stackoverflow.com/questions/26584451/how-to-disable-animations-in-protractor-for-angular-js-appliction
var disableNgAnimate = function() {
angular
.module('disableNgAnimate', [])
.run(['$animate', function($animate) {
$animate.enabled(false);
}]);
};
var disableCssAnimate = function() {
angular
.module('disableCssAnimate', [])
.run(function() {
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '* {' +
'-webkit-transition: none !important;' +
'-moz-transition: none !important' +
'-o-transition: none !important' +
'-ms-transition: none !important' +
'transition: none !important' +
'}';
document.getElementsByTagName('head')[0].appendChild(style);
});
};
// disable ng-animate during the testing
browser.addMockModule('disableNgAnimate', disableNgAnimate);
browser.addMockModule('disableCssAnimate', disableCssAnimate);
}
};