-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
172 lines (153 loc) · 6.33 KB
/
Gruntfile.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
module.exports = function(grunt) {
var platform = grunt.option('platform'),
testHost = grunt.option('host'),
selenium = grunt.option('selenium'),
moment = require('moment');
require('load-grunt-tasks')(grunt);
grunt.initConfig({
protractor_webdriver: {
options: {
path: 'node_modules/protractor/bin/',
keepAlive: true
},
update: {
options: {
//role: 'hub',
command: 'webdriver-manager update' // --role=hub, which will work if args are passed!
}
},
start: {
options: {
//role: 'hub',
command: 'webdriver-manager start' // --role=hub, which will work if args are passed!
}
}
},
protractor: {
options: {
keepAlive: true, // If false, the grunt process stops when the test fails.
noColor: false // If true, protractor will not use colors in its output.
},
dev: {
options: {
configFile: 'test/e2e/protractor-conf.js',
args: {
seleniumAddress: selenium||process.env.SELENIUM_SERVER||'http://localhost:4444/wd/hub',
baseUrl: testHost||process.env.HOST||'https://www.travelsupermarket.com/',
cucumberOpts: {
tags: ['~@ignore','<%= protractor.platformTag%>']
}
}
}
},
wip: {
options: {
configFile: 'test/e2e/protractor-conf.js',
args: {
seleniumAddress: selenium||process.env.SELENIUM_SERVER||'http://localhost:4444/wd/hub',
baseUrl: testHost||process.env.HOST||'https://www.travelsupermarket.com/',
cucumberOpts: {
tags: ['@wip','<%= protractor.platformTag%>']
}
}
}
},
all: {
options: {
configFile: 'test/e2e/protractor-conf-multirun.js',
args: {
seleniumAddress: selenium||process.env.SELENIUM_SERVER||'http://localhost:4444/wd/hub',
baseUrl: testHost||process.env.HOST||'https://www.travelsupermarket.com/',
cucumberOpts: {
tags: ['~@ignore','@desktop','@mobile','@tabletL','@tabletP','@journey']
}
}
}
},
func: {
options: {
configFile: 'test/e2e/protractor-conf-multifunc.js',
args: {
seleniumAddress: selenium||process.env.SELENIUM_SERVER||'http://localhost:4444/wd/hub',
baseUrl: testHost||process.env.HOST||'https://www.travelsupermarket.com/',
cucumberOpts: {
tags: ['~@ignore','~@journey','<%= protractor.platformTag%>']
}
}
}
}
},
'protractor-cucumber-html-report': {
options: {
dest: 'test/e2e/reports/cucumberHtml',
output: 'report.html',
testJSONDirectory: 'test/e2e/reports/cucumber'
},
dev: {
reportTitle: 'Test report generated by dev run'
},
wip: {
reportTitle: 'Test report generated by wip run'
},
all: {
reportTitle: 'Test report generated by all run'
},
func: {
reportTitle: 'Test report generated by func run'
}
},
});
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.loadNpmTasks('grunt-protractor-webdriver');
grunt.loadNpmTasks('grunt-protractor-cucumber-html-report');
grunt.registerTask('e2e', 'Run e2e tests', function(target) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED=0;
process.env.START_TIME = moment().format('X');
var platformTag = '';
if (platform){
process.env.PLATFORM=platform;
}
if(!process.env.PLATFORM){
process.env.PLATFORM='desktop';
}
if (selenium){
process.env.SELENIUM_SERVER=selenium;
}
if(!process.env.SELENIUM_SERVER){
process.env.SELENIUM_SERVER='http://localhost:4444/wd/hub';
}
if (testHost){
process.env.HOST=testHost;
}
if(!process.env.HOST){
process.env.HOST='https://www.travelsupermarket.com/';
}
if(process.env.PLATFORM !== 'mobile' && process.env.PLATFORM !== 'desktop' && process.env.PLATFORM !== 'tabletP' && process.env.PLATFORM !== 'tabletL'){
throw Error('Wrong type of platform: '+process.env.PLATFORM+'. Should be desktop, mobile, tabletP or tabletL.');
}
platformTag = '@'+ process.env.PLATFORM;
grunt.log.writeflags(platformTag, 'Protractor');
grunt.config.set('protractor.platformTag', platformTag);
console.log(' \nTest ENVIRONMENT: ');
console.log(' '+process.env.HOST);
console.log(' \nUsing Selenium Grid: ');
console.log(' '+process.env.SELENIUM_SERVER);
if(target !== 'all'){
console.log(' \nRun tests on platform: ');
console.log(' '+process.env.PLATFORM);
}
console.log(' \nTest start time: ');
console.log(' '+moment.unix(process.env.START_TIME).format('h:mm:ss a'));
console.log('\n');
target = target || 'dev';
process.env.RUN_TYPE = target;
if(process.env.SELENIUM_SERVER === 'http://localhost:4444/wd/hub'){
grunt.task.run(['protractor_webdriver:start', 'protractor:'+target , 'protractor-cucumber-html-report:'+target]);
}else{
grunt.task.run(['protractor:'+target , 'protractor-cucumber-html-report:'+target]);
}
});
grunt.registerTask('webdriver', 'webdriver items', function(target) {
grunt.task.run(['protractor_webdriver:'+target]);
});
};