@@ -12,16 +12,16 @@ let getBaseConfig = function() {
12
12
username : 'BROWSERSTACK_USER' ,
13
13
key : 'BROWSERSTACK_KEY' ,
14
14
test_framework : 'qunit' ,
15
- test_path : path . resolve ( __dirname , 'resources' , 'sample .html' ) ,
15
+ test_path : path . resolve ( __dirname , 'resources' , 'qunit_sample .html' ) ,
16
16
build : "BrowserStack Runner Behaviour Tests" ,
17
17
browsers : [ {
18
18
browser : 'firefox' ,
19
- browser_version : 'latest ' ,
19
+ browser_version : '47.0 ' ,
20
20
os : 'Windows' ,
21
21
os_version : '7'
22
22
} , {
23
23
browser : 'chrome' ,
24
- browser_version : 'latest ' ,
24
+ browser_version : '52.0 ' ,
25
25
os : 'Windows' ,
26
26
os_version : '7'
27
27
} ]
@@ -97,7 +97,6 @@ describe('Pass/Fail reporting', function() {
97
97
98
98
it ( 'report keys should have browser names' , function ( done ) {
99
99
let config = getBaseConfig ( ) ;
100
- config . test_path = path . resolve ( __dirname , 'resources' , 'sample_failing.html' ) ;
101
100
browserstackRunner . run ( config , function ( err , report ) {
102
101
assert . equal ( err , null ) ;
103
102
var parsedReport = JSON . parse ( report ) ;
@@ -108,7 +107,6 @@ describe('Pass/Fail reporting', function() {
108
107
} ) ;
109
108
it ( 'report keys should have assertions and tests' , function ( done ) {
110
109
let config = getBaseConfig ( ) ;
111
- config . test_path = path . resolve ( __dirname , 'resources' , 'sample_failing.html' ) ;
112
110
browserstackRunner . run ( config , function ( err , report ) {
113
111
assert . equal ( err , null ) ;
114
112
var parsedReport = JSON . parse ( report ) ;
@@ -120,19 +118,89 @@ describe('Pass/Fail reporting', function() {
120
118
} ) ;
121
119
} ) ;
122
120
describe ( 'Test Assertions' , function ( ) {
123
- it ( 'report should have proper assertions for tests' , function ( done ) {
121
+ it ( 'report should have proper number of assertions for tests' , function ( done ) {
124
122
let config = getBaseConfig ( ) ;
125
- config . test_path = path . resolve ( __dirname , 'resources' , 'sample_failing.html' ) ;
126
123
browserstackRunner . run ( config , function ( err , report ) {
127
124
assert . equal ( err , null ) ;
125
+ console . log ( report ) ;
128
126
var parsedReport = JSON . parse ( report ) ;
129
- //assert.equal(parsedReport["Windows 7, Chrome 52.0"].assertions.length, 6);
130
- //assert.equal(parsedReport["Windows 7, Firefox 47.0"].assertions.length, 6);
131
- //console.log("REPORT!! " + JSON.stringify( parsedReport["Windows 7, Chrome 52.0"] ));
127
+ // Only failed assertions are emitted
128
+ assert . equal ( parsedReport [ "Windows 7, Chrome 52.0" ] . assertions . length , 8 ) ;
129
+ assert . equal ( parsedReport [ "Windows 7, Firefox 47.0" ] . assertions . length , 8 ) ;
130
+ done ( ) ;
131
+ } ) ;
132
+ } ) ;
133
+ it ( 'report should have specific keys' , function ( done ) {
134
+ let config = getBaseConfig ( ) ;
135
+ console . log ( JSON . stringify ( config ) ) ;
136
+ browserstackRunner . run ( config , function ( err , report ) {
137
+ assert . equal ( err , null ) ;
138
+ var parsedReport = JSON . parse ( report ) ;
139
+ Object . keys ( parsedReport ) . forEach ( function ( reportKey ) {
140
+ parsedReport [ reportKey ] . assertions . forEach ( function ( assertion ) {
141
+ [ "actual" , "expected" , "message" , "source" ] . forEach ( function ( key ) {
142
+ assert . notEqual ( assertion [ key ] , null ) ;
143
+ } ) ;
144
+ } ) ;
145
+ } ) ;
146
+ done ( ) ;
147
+ } ) ;
148
+ } ) ;
149
+ it ( 'report should have message in assertions' , function ( done ) {
150
+ let config = getBaseConfig ( ) ;
151
+ console . log ( JSON . stringify ( config ) ) ;
152
+ browserstackRunner . run ( config , function ( err , report ) {
153
+ assert . equal ( err , null ) ;
154
+ var parsedReport = JSON . parse ( report ) ;
155
+ Object . keys ( parsedReport ) . forEach ( function ( reportKey ) {
156
+ parsedReport [ reportKey ] . assertions . forEach ( function ( assertion ) {
157
+ assert . notEqual ( assertion [ "message" ] . match ( / \d + i s .* a n .* n u m b e r / ) , null ) ;
158
+ } ) ;
159
+ } ) ;
132
160
done ( ) ;
133
161
} ) ;
134
162
} ) ;
135
163
} ) ;
136
164
describe ( 'Test tests' , function ( ) {
165
+ it ( 'report should have proper number of tests' , function ( done ) {
166
+ let config = getBaseConfig ( ) ;
167
+ browserstackRunner . run ( config , function ( err , report ) {
168
+ assert . equal ( err , null ) ;
169
+ var parsedReport = JSON . parse ( report ) ;
170
+ assert . equal ( parsedReport [ "Windows 7, Chrome 52.0" ] . tests . length , 1 ) ;
171
+ assert . equal ( parsedReport [ "Windows 7, Firefox 47.0" ] . tests . length , 1 ) ;
172
+ done ( ) ;
173
+ } ) ;
174
+ } ) ;
175
+ it ( 'report should have specific keys' , function ( done ) {
176
+ let config = getBaseConfig ( ) ;
177
+ browserstackRunner . run ( config , function ( err , report ) {
178
+ assert . equal ( err , null ) ;
179
+ var parsedReport = JSON . parse ( report ) ;
180
+ Object . keys ( parsedReport ) . forEach ( function ( reportKey ) {
181
+ parsedReport [ reportKey ] . tests . forEach ( function ( test ) {
182
+ [ "runtime" , "total" , "passed" , "failed" , "url" ] . forEach ( function ( key ) {
183
+ assert . notEqual ( test [ key ] , null ) ;
184
+ } ) ;
185
+ } ) ;
186
+ } ) ;
187
+ done ( ) ;
188
+ } ) ;
189
+ } ) ;
190
+ it ( 'report should have message in assertions' , function ( done ) {
191
+ let config = getBaseConfig ( ) ;
192
+ browserstackRunner . run ( config , function ( err , report ) {
193
+ assert . equal ( err , null ) ;
194
+ var parsedReport = JSON . parse ( report ) ;
195
+ Object . keys ( parsedReport ) . forEach ( function ( reportKey ) {
196
+ parsedReport [ reportKey ] . tests . forEach ( function ( test ) {
197
+ assert . equal ( test [ "total" ] , 3 ) ;
198
+ assert . equal ( test [ "passed" ] , 1 ) ;
199
+ assert . equal ( test [ "failed" ] , 2 ) ;
200
+ } ) ;
201
+ } ) ;
202
+ done ( ) ;
203
+ } ) ;
204
+ } ) ;
137
205
} ) ;
138
206
} ) ;
0 commit comments