11'use strict' ;
22
3- global . logLevel = " silent" ;
3+ global . logLevel = ' silent' ;
44
5- let assert = require ( 'assert' ) ,
5+ var assert = require ( 'assert' ) ,
66 sinon = require ( 'sinon' ) ,
77 path = require ( 'path' ) ,
8- browserstackRunner = require ( '../../bin/cli.js' ) ;
8+ http = require ( 'http' ) ,
9+ browserstackRunner = require ( '../../bin/cli.js' ) ,
10+ Tunnel = require ( '../../lib/local.js' ) . Tunnel ;
911
10- let getBaseConfig = function ( ) {
12+ var getBaseConfig = function ( ) {
1113 return {
1214 username : 'BROWSERSTACK_USER' ,
1315 key : 'BROWSERSTACK_KEY' ,
1416 test_framework : 'qunit' ,
1517 test_path : path . resolve ( __dirname , 'resources' , 'qunit_sample.html' ) ,
16- build : " BrowserStack Runner Behaviour Tests" ,
18+ build : ' BrowserStack Runner Behaviour Tests' ,
1719 browsers : [ {
1820 browser : 'firefox' ,
1921 browser_version : '47.0' ,
@@ -38,26 +40,26 @@ describe('Config Assertions', function() {
3840 } ) ;
3941 } ) ;
4042 it ( 'should have an error if test path is not valid' , function ( done ) {
41- let config = getBaseConfig ( ) ;
42- config . test_path = " Some invalid path" ;
43+ var config = getBaseConfig ( ) ;
44+ config . test_path = ' Some invalid path' ;
4345 browserstackRunner . run ( config , function ( err ) {
44- assert . equal ( err . message , " Test path: " + config . test_path + " is invalid." ) ;
46+ assert . equal ( err . message , ' Test path: ' + config . test_path + ' is invalid.' ) ;
4547 done ( ) ;
4648 } ) ;
4749 } ) ;
4850 it ( 'should have an error if config does not have a browsers key' , function ( done ) {
49- let config = getBaseConfig ( ) ;
51+ var config = getBaseConfig ( ) ;
5052 delete ( config . browsers ) ;
5153 browserstackRunner . run ( config , function ( err ) {
52- assert . equal ( err . message , " Configuration parameter browsers is required." ) ;
54+ assert . equal ( err . message , ' Configuration parameter browsers is required.' ) ;
5355 done ( ) ;
5456 } ) ;
5557 } ) ;
5658 it ( 'should have an error if config does not have a test_path key' , function ( done ) {
57- let config = getBaseConfig ( ) ;
59+ var config = getBaseConfig ( ) ;
5860 delete ( config . test_path ) ;
5961 browserstackRunner . run ( config , function ( err ) {
60- assert . equal ( err . message , " Configuration parameter test_path is required." ) ;
62+ assert . equal ( err . message , ' Configuration parameter test_path is required.' ) ;
6163 done ( ) ;
6264 } ) ;
6365 } ) ;
@@ -70,18 +72,18 @@ describe('Config Assertions', function() {
7072 } ) ;
7173
7274 it ( 'should have an error if config does not have a username' , function ( done ) {
73- let config = getBaseConfig ( ) ;
75+ var config = getBaseConfig ( ) ;
7476 delete ( config . username ) ;
7577 browserstackRunner . run ( config , function ( err ) {
76- assert . equal ( err . message , " Configuration parameter username is required." ) ;
78+ assert . equal ( err . message , ' Configuration parameter username is required.' ) ;
7779 done ( ) ;
7880 } ) ;
7981 } ) ;
8082 it ( 'should have an error if config does not have a key' , function ( done ) {
81- let config = getBaseConfig ( ) ;
83+ var config = getBaseConfig ( ) ;
8284 delete ( config . key ) ;
8385 browserstackRunner . run ( config , function ( err ) {
84- assert . equal ( err . message , " Configuration parameter key is required." ) ;
86+ assert . equal ( err . message , ' Configuration parameter key is required.' ) ;
8587 done ( ) ;
8688 } ) ;
8789 } ) ;
@@ -96,47 +98,43 @@ describe('Pass/Fail reporting', function() {
9698 this . timeout ( 0 ) ;
9799
98100 it ( 'report keys should have browser names' , function ( done ) {
99- let config = getBaseConfig ( ) ;
101+ var config = getBaseConfig ( ) ;
100102 browserstackRunner . run ( config , function ( err , report ) {
101103 assert . equal ( err , null ) ;
102- var parsedReport = JSON . parse ( report ) ;
103- assert . notEqual ( parsedReport [ "Windows 7, Chrome 52.0" ] , null ) ;
104- assert . notEqual ( parsedReport [ "Windows 7, Firefox 47.0" ] , null ) ;
104+ assert . notEqual ( report [ 'Windows 7, Chrome 52.0' ] , null ) ;
105+ assert . notEqual ( report [ 'Windows 7, Firefox 47.0' ] , null ) ;
105106 done ( ) ;
106107 } ) ;
107108 } ) ;
108109 it ( 'report keys should have assertions and tests' , function ( done ) {
109- let config = getBaseConfig ( ) ;
110+ var config = getBaseConfig ( ) ;
110111 browserstackRunner . run ( config , function ( err , report ) {
111112 assert . equal ( err , null ) ;
112- var parsedReport = JSON . parse ( report ) ;
113- assert . notEqual ( parsedReport [ "Windows 7, Chrome 52.0" ] . assertions , null ) ;
114- assert . notEqual ( parsedReport [ "Windows 7, Chrome 52.0" ] . tests , null ) ;
115- assert . notEqual ( parsedReport [ "Windows 7, Firefox 47.0" ] . assertions , null ) ;
116- assert . notEqual ( parsedReport [ "Windows 7, Firefox 47.0" ] . tests , null ) ;
113+ assert . notEqual ( report [ 'Windows 7, Chrome 52.0' ] . assertions , null ) ;
114+ assert . notEqual ( report [ 'Windows 7, Chrome 52.0' ] . tests , null ) ;
115+ assert . notEqual ( report [ 'Windows 7, Firefox 47.0' ] . assertions , null ) ;
116+ assert . notEqual ( report [ 'Windows 7, Firefox 47.0' ] . tests , null ) ;
117117 done ( ) ;
118118 } ) ;
119119 } ) ;
120120 describe ( 'Test Assertions' , function ( ) {
121121 it ( 'report should have proper number of assertions for tests' , function ( done ) {
122- let config = getBaseConfig ( ) ;
122+ var config = getBaseConfig ( ) ;
123123 browserstackRunner . run ( config , function ( err , report ) {
124124 assert . equal ( err , null ) ;
125- var parsedReport = JSON . parse ( report ) ;
126125 // Only failed assertions are emitted
127- assert . equal ( parsedReport [ " Windows 7, Chrome 52.0" ] . assertions . length , 8 ) ;
128- assert . equal ( parsedReport [ " Windows 7, Firefox 47.0" ] . assertions . length , 8 ) ;
126+ assert . equal ( report [ ' Windows 7, Chrome 52.0' ] . assertions . length , 8 ) ;
127+ assert . equal ( report [ ' Windows 7, Firefox 47.0' ] . assertions . length , 8 ) ;
129128 done ( ) ;
130129 } ) ;
131130 } ) ;
132131 it ( 'report should have specific keys' , function ( done ) {
133- let config = getBaseConfig ( ) ;
132+ var config = getBaseConfig ( ) ;
134133 browserstackRunner . run ( config , function ( err , report ) {
135134 assert . equal ( err , null ) ;
136- var parsedReport = JSON . parse ( report ) ;
137- Object . keys ( parsedReport ) . forEach ( function ( reportKey ) {
138- parsedReport [ reportKey ] . assertions . forEach ( function ( assertion ) {
139- [ "actual" , "expected" , "message" , "source" ] . forEach ( function ( key ) {
135+ Object . keys ( report ) . forEach ( function ( reportKey ) {
136+ report [ reportKey ] . assertions . forEach ( function ( assertion ) {
137+ [ 'actual' , 'expected' , 'message' , 'source' ] . forEach ( function ( key ) {
140138 assert . notEqual ( assertion [ key ] , null ) ;
141139 } ) ;
142140 } ) ;
@@ -145,13 +143,12 @@ describe('Pass/Fail reporting', function() {
145143 } ) ;
146144 } ) ;
147145 it ( 'report should have message in assertions' , function ( done ) {
148- let config = getBaseConfig ( ) ;
146+ var config = getBaseConfig ( ) ;
149147 browserstackRunner . run ( config , function ( err , report ) {
150148 assert . equal ( err , null ) ;
151- var parsedReport = JSON . parse ( report ) ;
152- Object . keys ( parsedReport ) . forEach ( function ( reportKey ) {
153- parsedReport [ reportKey ] . assertions . forEach ( function ( assertion ) {
154- assert . notEqual ( assertion [ "message" ] . match ( / \d + i s .* a n .* n u m b e r / ) , null ) ;
149+ Object . keys ( report ) . forEach ( function ( reportKey ) {
150+ report [ reportKey ] . assertions . forEach ( function ( assertion ) {
151+ assert . notEqual ( assertion [ 'message' ] . match ( / \d + i s .* a n .* n u m b e r / ) , null ) ;
155152 } ) ;
156153 } ) ;
157154 done ( ) ;
@@ -160,23 +157,21 @@ describe('Pass/Fail reporting', function() {
160157 } ) ;
161158 describe ( 'Test tests' , function ( ) {
162159 it ( 'report should have proper number of tests' , function ( done ) {
163- let config = getBaseConfig ( ) ;
160+ var config = getBaseConfig ( ) ;
164161 browserstackRunner . run ( config , function ( err , report ) {
165162 assert . equal ( err , null ) ;
166- var parsedReport = JSON . parse ( report ) ;
167- assert . equal ( parsedReport [ "Windows 7, Chrome 52.0" ] . tests . length , 1 ) ;
168- assert . equal ( parsedReport [ "Windows 7, Firefox 47.0" ] . tests . length , 1 ) ;
163+ assert . equal ( report [ 'Windows 7, Chrome 52.0' ] . tests . length , 1 ) ;
164+ assert . equal ( report [ 'Windows 7, Firefox 47.0' ] . tests . length , 1 ) ;
169165 done ( ) ;
170166 } ) ;
171167 } ) ;
172168 it ( 'report should have specific keys' , function ( done ) {
173- let config = getBaseConfig ( ) ;
169+ var config = getBaseConfig ( ) ;
174170 browserstackRunner . run ( config , function ( err , report ) {
175171 assert . equal ( err , null ) ;
176- var parsedReport = JSON . parse ( report ) ;
177- Object . keys ( parsedReport ) . forEach ( function ( reportKey ) {
178- parsedReport [ reportKey ] . tests . forEach ( function ( test ) {
179- [ "runtime" , "total" , "passed" , "failed" , "url" ] . forEach ( function ( key ) {
172+ Object . keys ( report ) . forEach ( function ( reportKey ) {
173+ report [ reportKey ] . tests . forEach ( function ( test ) {
174+ [ 'runtime' , 'total' , 'passed' , 'failed' , 'url' ] . forEach ( function ( key ) {
180175 assert . notEqual ( test [ key ] , null ) ;
181176 } ) ;
182177 } ) ;
@@ -185,15 +180,14 @@ describe('Pass/Fail reporting', function() {
185180 } ) ;
186181 } ) ;
187182 it ( 'report should have message in assertions' , function ( done ) {
188- let config = getBaseConfig ( ) ;
183+ var config = getBaseConfig ( ) ;
189184 browserstackRunner . run ( config , function ( err , report ) {
190185 assert . equal ( err , null ) ;
191- var parsedReport = JSON . parse ( report ) ;
192- Object . keys ( parsedReport ) . forEach ( function ( reportKey ) {
193- parsedReport [ reportKey ] . tests . forEach ( function ( test ) {
194- assert . equal ( test [ "total" ] , 3 ) ;
195- assert . equal ( test [ "passed" ] , 1 ) ;
196- assert . equal ( test [ "failed" ] , 2 ) ;
186+ Object . keys ( report ) . forEach ( function ( reportKey ) {
187+ report [ reportKey ] . tests . forEach ( function ( test ) {
188+ assert . equal ( test [ 'total' ] , 3 ) ;
189+ assert . equal ( test [ 'passed' ] , 1 ) ;
190+ assert . equal ( test [ 'failed' ] , 2 ) ;
197191 } ) ;
198192 } ) ;
199193 done ( ) ;
0 commit comments