diff --git a/Gruntfile.js b/Gruntfile.js index 49c2b1c..e9edb7a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,11 +1,3 @@ -/* - * CleverStack.io - * https://github.com/clevertech/cleverstack-angular-seed/ - * - * Copyright (c) 2013 Clevertech.biz - * Licensed under the MIT license. - */ - 'use strict'; var fs = require('fs'); @@ -603,6 +595,41 @@ module.exports = function (grunt) { dir: '<%= appConfig.test.e2e.coverage.path %>reports', print: 'detail' } + }, + run: { + wbDriverUpdate: { + args: [ './node_modules/protractor/bin/webdriver-manager', 'update', '--out_dir="./scripts/"' ], + options: { + passArgs: [ + 'ie', + 'chrome', + 'standalone', + 'seleniumPort' + ] + } + }, + wbDriverStatus: { + args: [ './node_modules/protractor/bin/webdriver-manager', 'status', '--out_dir="./scripts/"' ], + options: { + passArgs: [ + 'ie', + 'chrome', + 'standalone', + 'seleniumPort' + ] + } + }, + wbDriverStart: { + args: [ './node_modules/protractor/bin/webdriver-manager', 'start', '--out_dir="./scripts/"' ], + options: { + passArgs: [ + 'ie', + 'chrome', + 'standalone', + 'seleniumPort' + ] + } + } } }); @@ -634,6 +661,23 @@ module.exports = function (grunt) { 'usemin' ]); + grunt.registerTask( 'webdriver', [ + 'run:wbDriverStatus', + 'run:wbDriverUpdate' + ]); + + grunt.registerTask( 'webdriver:update', [ + 'run:wbDriverUpdate' + ]); + + grunt.registerTask( 'webdriver:status', [ + 'run:wbDriverStatus' + ]); + + grunt.registerTask( 'webdriver:start', [ + 'run:wbDriverStart' + ]); + /* -- TEST TASKS ------------------------------------------------ */ grunt.registerTask('test', 'Start up the auto unit test server.', [ diff --git a/package.json b/package.json index 5d653c8..c86fa0a 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ ], "license": "BSD-2-Clause", "dependencies": {}, - "devDependencies": { + "devDependencies": { "grunt-concurrent": "~0.4.1", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-concat": "~0.3.0", @@ -52,6 +52,7 @@ "grunt-protractor-coverage": "^0.2.8", "grunt-protractor-runner": "~0.1.6", "grunt-rev": "~0.1.0", + "grunt-run": "~0.2.2", "grunt-usemin": "~0.1.12", "karma": "~0.11.11", "karma-browserstack-launcher": "~0.0.7", @@ -67,8 +68,8 @@ "karma-phantomjs-launcher": "~0.1.1", "karma-requirejs": "~0.2.0", "karma-safari-launcher": "~0.1.1", - "karma-script-launcher": "~0.1.0", "karma-sauce-launcher": "~0.2.8", + "karma-script-launcher": "~0.1.0", "load-grunt-tasks": "~0.2.0", "phantomjs": "~1.9.2", "protractor": "~0.24.2", @@ -76,11 +77,11 @@ }, "scripts": { "setup": "node scripts/setup", - "setup-protractor": "node scripts/setup-protractor", + "setup-protractor": "grunt webdriver:update", "start": "grunt server", "bs-tunnel-karma": "sh scripts/bs-tunnel-karma.sh", "bs-tunnel": "sh scripts/bs-tunnel-connect.sh", "test": "grunt test:travis", "testos": "node scripts/testos" } -} \ No newline at end of file +} diff --git a/scripts/setup-protractor.js b/scripts/setup-protractor.js deleted file mode 100644 index 3cbb857..0000000 --- a/scripts/setup-protractor.js +++ /dev/null @@ -1,73 +0,0 @@ -var async_exec = require( 'child_process' ).exec - -async_exec( 'npm install shelljs', function( err, stdout, stderr ) { - require( 'shelljs/global' ); - - //detect OS - var os = require( 'os' ) - , isWin = /^win32/.test( os.platform() ) - , isLinux = /^linux/.test( os.platform() ) - , isMac = /^darwin/.test( os.platform() ) || /^freebsd/.test( os.platform() ); - - echo( 'About to setup protractor and dependencies.' ); - echo( 'It works if it finishes with OK' ); - - //Selenium Standalone Server - required for protractor e2e testing - //Note: Protractor comes with a script to help download and install the standalone server. Run 'webdriver-manager-update': https://github.com/angular/protractor/blob/master/docs/getting-started.md - //https://code.google.com/p/selenium/downloads/list - //Size: ~33mb - echo( 'Downloading specific Selenium Server jar...' ); - exec( 'wget http://selenium.googlecode.com/files/selenium-server-standalone-2.39.0.jar' ); - exec( 'mv selenium-server-standalone-2.39.0.jar scripts/selenium-server-standalone-2.39.0.jar' ); - - //Chrome driver required to run Chrome on Selenium Server - //Note: download file is based on OS (CLI to handle which one to download) - //http://chromedriver.storage.googleapis.com/index.html - //Size: ~6mb - var chromedriverLink; - if (isWin) { - chromedriverLink = 'chromedriver_win32.zip'; - } else if (isLinux) { - chromedriverLink = 'chromedriver_linux32.zip'; - } else if (isMac) { - chromedriverLink = 'chromedriver_mac32.zip'; - } - echo( 'Downloading OS specific Chromedriver...' ); - exec( 'wget http://chromedriver.storage.googleapis.com/2.8/' + chromedriverLink); - exec( 'unzip ' + chromedriverLink ); - - if ( isWin ) { - exec( 'mv Chromedriver.exe scripts/Chromedriver.exe' ); - } else { - exec( 'mv Chromedriver scripts/Chromedriver' ); - } - exec( 'rm ' + chromedriverLink ); - - //PhantomJS driver required to run on Selenium Server - //Note: download file is based on OS (CLI to handle which one to download) - //http://phantomjs.org/download.html - //Size: ~7mb - var phantomjsLink, linkExt; - if ( isWin ) { - phantomjsLink = 'phantomjs-1.9.2-windows'; - linkExt = '.zip'; - } else if ( isLinux ) { - phantomjsLink = 'phantomjs-1.9.2-linux-i686'; - linkExt = '.tar.bz2'; - } else if ( isMac ) { - phantomjsLink = 'phantomjs-1.9.2-macosx'; - linkExt = '.zip'; - } - echo( 'Downloading OS specific Phantomjs...' ); - exec( 'wget http://phantomjs.googlecode.com/files/' + phantomjsLink + linkExt ); - if (isLinux) { - exec( 'tar -xjvf ' + phantomjsLink + linkExt ); - } else { - exec( 'unzip ' + phantomjsLink + linkExt ); - } - exec( 'mv ' + phantomjsLink + '/phantomjs.exe scripts/phantomjs.exe' ); - exec( 'rm ' + phantomjsLink + linkExt); - exec( 'rm -rf ' + phantomjsLink ); - - echo( 'OK!' ); -}); \ No newline at end of file diff --git a/test-e2e.conf.js b/test-e2e.conf.js index 04c4fa4..4287db5 100644 --- a/test-e2e.conf.js +++ b/test-e2e.conf.js @@ -67,7 +67,7 @@ exports.config = { */ // capabilities: { // 'browserName': 'phantomjs', - // 'phantomjs.binary.path': './scripts/phantomjs.exe' + // 'phantomjs.binary.path': './node_modules/phantom/bin/phantomjs' // }, // A base URL for your application under test. Calls to protractor.get()