@@ -497,58 +497,59 @@ describe('Runner', function () {
497497 } ) ;
498498
499499 it ( 'Should raise an error if speed option has wrong value' , function ( ) {
500- var incorrectSpeedErrorMessage = 'Speed should be a number between 0.01 and 1.' ;
500+ var exceptionCount = 0 ;
501+ var incorrectSpeedError = function ( speed ) {
502+ return runner
503+ . run ( { speed } )
504+ . catch ( function ( err ) {
505+ exceptionCount ++ ;
506+ expect ( err . message ) . eql ( 'Speed should be a number between 0.01 and 1.' ) ;
507+ } ) ;
508+ } ;
501509
502- return testCafe
503- . createBrowserConnection ( )
504- . then ( function ( browserConnection ) {
505- return runner
506- . browsers ( browserConnection )
507- . run ( { speed : 'yo' } ) ;
508- } )
509- . catch ( function ( err ) {
510- expect ( err . message ) . eql ( incorrectSpeedErrorMessage ) ;
511- } )
512- . then ( function ( ) {
513- return runner . run ( { speed : - 0.01 } ) ;
514- } ) . catch ( function ( err ) {
515- expect ( err . message ) . eql ( incorrectSpeedErrorMessage ) ;
516- } )
517- . then ( function ( ) {
518- return runner . run ( { speed : 1.01 } ) ;
519- } ) . catch ( function ( err ) {
520- expect ( err . message ) . eql ( incorrectSpeedErrorMessage ) ;
521- } ) ;
510+ return Promise . resolve ( )
511+ . then ( ( ) => incorrectSpeedError ( 'yo' ) )
512+ . then ( ( ) => incorrectSpeedError ( - 0.01 ) )
513+ . then ( ( ) => incorrectSpeedError ( 0 ) )
514+ . then ( ( ) => incorrectSpeedError ( 1.01 ) )
515+ . then ( ( ) => expect ( exceptionCount ) . to . be . eql ( 4 ) ) ;
522516 } ) ;
523517
524518 it ( 'Should raise an error if concurrency option has wrong value' , function ( ) {
525- var incorrectConcurrencyFactorErrorMessage = 'The concurrency factor should be an integer greater or equal to 1.' ;
519+ var exceptionCount = 0 ;
520+ var incorrectConcurrencyFactorError = function ( concurrency ) {
521+ return runner
522+ . concurrency ( concurrency )
523+ . run ( )
524+ . catch ( function ( err ) {
525+ exceptionCount ++ ;
526+ expect ( err . message ) . eql ( 'The concurrency factor should be an integer greater or equal to 1.' ) ;
527+ } ) ;
528+ } ;
526529
527- return testCafe
528- . createBrowserConnection ( )
529- . then ( function ( browserConnection ) {
530- return runner
531- . browsers ( browserConnection )
532- . concurrency ( 'yo' ) ;
533- } )
534- . catch ( function ( err ) {
535- expect ( err . message ) . eql ( incorrectConcurrencyFactorErrorMessage ) ;
536- } )
537- . then ( function ( ) {
538- return runner . concurrency ( - 1 ) ;
539- } ) . catch ( function ( err ) {
540- expect ( err . message ) . eql ( incorrectConcurrencyFactorErrorMessage ) ;
541- } )
542- . then ( function ( ) {
543- return runner . concurrency ( 0.1 ) ;
544- } ) . catch ( function ( err ) {
545- expect ( err . message ) . eql ( incorrectConcurrencyFactorErrorMessage ) ;
546- } )
547- . then ( function ( ) {
548- return runner . concurrency ( 0 ) ;
549- } ) . catch ( function ( err ) {
550- expect ( err . message ) . eql ( incorrectConcurrencyFactorErrorMessage ) ;
551- } ) ;
530+ return Promise . resolve ( )
531+ . then ( ( ) => incorrectConcurrencyFactorError ( 'yo' ) )
532+ . then ( ( ) => incorrectConcurrencyFactorError ( - 1 ) )
533+ . then ( ( ) => incorrectConcurrencyFactorError ( 0.1 ) )
534+ . then ( ( ) => incorrectConcurrencyFactorError ( 0 ) )
535+ . then ( ( ) => expect ( exceptionCount ) . to . be . eql ( 4 ) ) ;
536+ } ) ;
537+
538+ it ( 'Should raise an error if proxyBypass option has wrong type' , function ( ) {
539+ var exceptionCount = 0 ;
540+ var expectProxyBypassError = function ( proxyBypass , type ) {
541+ runner . opts . proxyBypass = proxyBypass ;
542+ return runner . run ( )
543+ . catch ( function ( err ) {
544+ exceptionCount ++ ;
545+ expect ( err . message ) . contains ( '"proxyBypass" argument is expected to be a string, but it was ' + type ) ;
546+ } ) ;
547+ } ;
548+
549+ return expectProxyBypassError ( 1 , 'number' )
550+ . then ( ( ) => expectProxyBypassError ( { } , 'object' ) )
551+ . then ( ( ) => expectProxyBypassError ( true , 'bool' ) )
552+ . then ( ( ) => expect ( exceptionCount ) . to . be . eql ( 3 ) ) ;
552553 } ) ;
553554 } ) ;
554555
0 commit comments