@@ -10,7 +10,7 @@ module.exports = function (grunt) {
1010 'tasks/*.js' ,
1111 '<%= nodeunit.tests %>'
1212 ]
13- } ,
13+ } ,
1414
1515 instrument : {
1616 files : 'tasks/*.js' ,
@@ -55,50 +55,64 @@ module.exports = function (grunt) {
5555
5656 clean : {
5757 coverage : [ 'coverage/**' ] ,
58- snapshots : [ 'test/snapshots/*' ]
58+ snapshots : [ 'test/snapshots/*' ] ,
59+ screenshots : [ 'test/screenshots/*' ]
5960 } ,
6061
6162 'html-dom-snapshot' : {
6263 options : {
6364 browserCapabilities : {
6465 browserName : 'phantomjs'
6566 } ,
66- dest : 'test/snapshots'
67+ snapshots : 'test/snapshots'
6768 } ,
6869 'single-target.html' : {
6970 url : 'http://localhost:8881/test/pages/single-target.html'
7071 } ,
7172 others : {
7273 commands : [
7374 {
75+ options : {
76+ snapshots : null ,
77+ screenshots : 'test/screenshots'
78+ } ,
7479 file : 'static.html' ,
7580 url : 'http://localhost:8881/test/pages/static.html'
7681 } ,
7782 {
78- file : 'delayed.html ' ,
83+ file : 'delayed' ,
7984 url : 'http://localhost:8881/test/pages/delayed.html' ,
8085 wait : 200
8186 } ,
8287 {
83- file : 'dynamic.html' ,
88+ options : {
89+ screenshots : 'test/screenshots'
90+ } ,
91+ file : 'dynamic' ,
8492 url : 'http://localhost:8881/test/pages/dynamic.html' ,
8593 wait : '.dynamic'
8694 } ,
8795 {
88- file : 'dynamic-reverse.html' ,
96+ options : {
97+ viewport : {
98+ width : 1600 ,
99+ height : 900
100+ }
101+ } ,
102+ file : 'dynamic-reverse' ,
89103 url : 'http://localhost:8881/test/pages/dynamic-reverse.html' ,
90104 wait : '!.dynamic'
91105 } ,
92106 {
93- file : 'dynamic-delayed.html ' ,
107+ file : 'dynamic-delayed' ,
94108 url : 'http://localhost:8881/test/pages/dynamic-delayed.html' ,
95109 wait : [
96110 '.dynamic' ,
97111 200
98112 ]
99113 } ,
100114 {
101- file : 'dynamic-custom.html ' ,
115+ file : 'dynamic-custom' ,
102116 url : 'http://localhost:8881/test/pages/dynamic-custom.html' ,
103117 wait : function ( browser ) {
104118 return browser . waitForExist ( '.dynamic' , 1000 ) ;
@@ -108,24 +122,24 @@ module.exports = function (grunt) {
108122 options : {
109123 doctype : ''
110124 } ,
111- file : 'no-doctype.html ' ,
125+ file : 'no-doctype' ,
112126 url : 'http://localhost:8881/test/pages/no-doctype.html'
113127 } ,
114128 {
115129 url : 'http://localhost:8881/test/pages/dynamic-multiple.html'
116130 } ,
117131 {
118- file : 'dynamic-first.html '
132+ file : 'dynamic-first'
119133 } ,
120134 {
121135 wait : '.second' ,
122- file : 'dynamic-second.html '
136+ file : 'dynamic-second'
123137 } ,
124138 {
125139 wait : '.third'
126140 } ,
127141 {
128- file : 'dynamic-third.html '
142+ file : 'dynamic-third'
129143 }
130144 ]
131145 } ,
@@ -139,28 +153,45 @@ module.exports = function (grunt) {
139153 } ,
140154 'invalid-file' : {
141155 options : {
156+ screenshots : 'test/screenshots' ,
142157 force : true
143158 } ,
144159 pages : [
145160 {
146161 url : 'http://localhost:8881' ,
147- file : '// '
162+ file : '/\\//\\ '
148163 }
149164 ]
150165 } ,
151166 'invalid-dest' : {
152167 options : {
153- dest : '//' ,
168+ dest : '/ /' ,
154169 force : true
155170 } ,
156171 dummy : {
157- url : 'http://localhost:8881'
172+ url : 'http://localhost:8881' ,
173+ file : 'dummy'
158174 }
175+ } ,
176+ 'invalid-screenshots' : {
177+ options : {
178+ screenshots : '/ /' ,
179+ force : true
180+ } ,
181+ pages : [
182+ {
183+ url : 'http://localhost:8881' ,
184+ file : 'dummy'
185+ }
186+ ]
159187 }
160188 } ,
161189
162190 'selenium_standalone' : {
163- serverConfig : {
191+ options : {
192+ stopOnExit : true
193+ } ,
194+ server : {
164195 seleniumVersion : '3.7.1' ,
165196 seleniumDownloadURL : 'http://selenium-release.storage.googleapis.com' ,
166197 drivers : {
@@ -181,16 +212,14 @@ module.exports = function (grunt) {
181212 grunt . loadNpmTasks ( 'grunt-selenium-standalone' ) ;
182213 grunt . loadTasks ( coverage ? 'coverage/tasks' : 'tasks' ) ;
183214
184- grunt . registerTask ( 'default' , coverage ? [
185- 'clean' , 'eslint' , 'instrument' ,
186- 'selenium_standalone:serverConfig:install' ,
187- 'selenium_standalone:serverConfig:start' ,
188- 'connect' , 'html-dom-snapshot' ,
189- 'selenium_standalone:serverConfig:stop' ,
190- 'nodeunit' , 'storeCoverage' , 'makeReport' ] : [
191- 'clean' , 'eslint' ,
192- 'selenium_standalone:serverConfig:install' ,
193- 'selenium_standalone:serverConfig:start' ,
194- 'connect' , 'html-dom-snapshot' ,
195- 'selenium_standalone:serverConfig:stop' , 'nodeunit' ] ) ;
215+ const start = [ 'clean' , 'eslint' ] ,
216+ instrument = coverage ? [ 'instrument' ] : [ ] ,
217+ test = [ 'selenium_standalone:server:install' ,
218+ 'selenium_standalone:server:start' ,
219+ 'connect' , 'html-dom-snapshot' ,
220+ 'selenium_standalone:server:stop' , 'nodeunit' ] ,
221+ report = coverage ? [ 'storeCoverage' , 'makeReport' ] : [ ] ;
222+ grunt . registerTask ( 'default' , start . concat ( instrument )
223+ . concat ( test )
224+ . concat ( report ) ) ;
196225} ;
0 commit comments