@@ -7,7 +7,9 @@ var assert = require('assert'),
77 path = require ( 'path' ) ,
88 http = require ( 'http' ) ,
99 browserstackRunner = require ( '../../bin/cli.js' ) ,
10- Tunnel = require ( '../../lib/local.js' ) . Tunnel ;
10+ Tunnel = require ( '../../lib/local.js' ) . Tunnel ,
11+ exec = require ( 'child_process' ) . exec ,
12+ execSync = require ( 'child_process' ) . execSync ;
1113
1214var getBaseConfig = function ( ) {
1315 return {
@@ -219,3 +221,39 @@ describe('Pass/Fail reporting', function() {
219221 } ) ;
220222 } ) ;
221223} ) ;
224+
225+ describe ( 'Command Line Interface Tests' , function ( ) {
226+ this . timeout ( 0 ) ;
227+ it ( 'Should run with valid CLI arguments' , function ( done ) {
228+ execSync ( 'bin/runner.js init' ) ;
229+ exec ( 'bin/runner.js --browsers 1 --path tests/behaviour/resources/qunit_sample.html' , null , function ( error , stdout , stderr ) {
230+ assert . equal ( error , null ) ;
231+ done ( ) ;
232+ } ) ;
233+ } ) ;
234+ it ( 'Should raise errors if all invalid browser keys.' , function ( done ) {
235+ exec ( 'bin/runner.js --browsers 10 --path tests/behaviour/resources/qunit_sample.html' , null , function ( error , stdout , stderr ) {
236+ assert . notEqual ( error . message . match ( 'Invalid' ) , null ) ;
237+ done ( ) ;
238+ } ) ;
239+ } ) ;
240+ it ( 'Should raise error if invalid test path' , function ( done ) {
241+ exec ( 'bin/runner.js --browsers 1 --path invalid/path' , function ( error , stdout , stderr ) {
242+ assert . notEqual ( error , null ) ;
243+ assert . notEqual ( error . message . match ( 'Invalid' ) , null ) ;
244+ done ( ) ;
245+ } ) ;
246+ } ) ;
247+ it ( 'Should run tests on browsers present if some keys not present' , function ( done ) {
248+ exec ( 'bin/runner.js --browsers 1 10 --path tests/behaviour/resources/qunit_sample.html' , null , function ( error , stdout , stderr ) {
249+ assert . equal ( error , null ) ;
250+ done ( ) ;
251+ } ) ;
252+ } ) ;
253+ it ( 'Should raise error if empty pid path with pid parameter' , function ( done ) {
254+ exec ( 'bin/runner.js --browsers 1 --path tests/behaviour/resources/qunit_sample.html --pid' , null , function ( error , stdout , stderr ) {
255+ assert . notEqual ( error , null ) ;
256+ done ( ) ;
257+ } ) ;
258+ } ) ;
259+ } ) ;
0 commit comments