@@ -12,16 +12,16 @@ let getBaseConfig = function() {
1212 username : 'BROWSERSTACK_USER' ,
1313 key : 'BROWSERSTACK_KEY' ,
1414 test_framework : 'qunit' ,
15- test_path : path . resolve ( __dirname , 'resources' , 'sample .html' ) ,
15+ test_path : path . resolve ( __dirname , 'resources' , 'qunit_sample .html' ) ,
1616 build : "BrowserStack Runner Behaviour Tests" ,
1717 browsers : [ {
1818 browser : 'firefox' ,
19- browser_version : 'latest ' ,
19+ browser_version : '47.0 ' ,
2020 os : 'Windows' ,
2121 os_version : '7'
2222 } , {
2323 browser : 'chrome' ,
24- browser_version : 'latest ' ,
24+ browser_version : '52.0 ' ,
2525 os : 'Windows' ,
2626 os_version : '7'
2727 } ]
@@ -97,7 +97,6 @@ describe('Pass/Fail reporting', function() {
9797
9898 it ( 'report keys should have browser names' , function ( done ) {
9999 let config = getBaseConfig ( ) ;
100- config . test_path = path . resolve ( __dirname , 'resources' , 'sample_failing.html' ) ;
101100 browserstackRunner . run ( config , function ( err , report ) {
102101 assert . equal ( err , null ) ;
103102 var parsedReport = JSON . parse ( report ) ;
@@ -108,7 +107,6 @@ describe('Pass/Fail reporting', function() {
108107 } ) ;
109108 it ( 'report keys should have assertions and tests' , function ( done ) {
110109 let config = getBaseConfig ( ) ;
111- config . test_path = path . resolve ( __dirname , 'resources' , 'sample_failing.html' ) ;
112110 browserstackRunner . run ( config , function ( err , report ) {
113111 assert . equal ( err , null ) ;
114112 var parsedReport = JSON . parse ( report ) ;
@@ -120,19 +118,89 @@ describe('Pass/Fail reporting', function() {
120118 } ) ;
121119 } ) ;
122120 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 ) {
124122 let config = getBaseConfig ( ) ;
125- config . test_path = path . resolve ( __dirname , 'resources' , 'sample_failing.html' ) ;
126123 browserstackRunner . run ( config , function ( err , report ) {
127124 assert . equal ( err , null ) ;
125+ console . log ( report ) ;
128126 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+ } ) ;
132160 done ( ) ;
133161 } ) ;
134162 } ) ;
135163 } ) ;
136164 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+ } ) ;
137205 } ) ;
138206} ) ;
0 commit comments