├── .gitignore ├── .jshintrc ├── .travis.yml ├── Gruntfile.js ├── LICENSE-MIT ├── README.md ├── package.json ├── scripts └── webdriver-manager-update ├── tasks └── protractor_runner.js └── test ├── argsTest.js ├── blankTest.js ├── failedTest.js ├── loginSuiteTest.js ├── logoutSuiteTest.js ├── objectArgs_test.js └── testConf.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | tmp 4 | selenium 5 | /*.iml 6 | .idea/ -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "immed": true, 5 | "latedef": true, 6 | "newcap": true, 7 | "noarg": true, 8 | "sub": true, 9 | "undef": true, 10 | "boss": true, 11 | "eqnull": true, 12 | "node": true 13 | } 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "6" 4 | - "7" 5 | before_script: 6 | - npm install -g grunt-cli 7 | before_install: 8 | - "wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -" 9 | - "sudo sh -c 'echo \"deb http://dl.google.com/linux/chrome/deb/ stable main\" >> /etc/apt/sources.list.d/google.list'" 10 | - "sudo apt-get update" 11 | - "sudo apt-get install google-chrome-stable" 12 | - "export DISPLAY=:99.0" 13 | - "sh -e /etc/init.d/xvfb start" 14 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-protractor-runner 3 | * https://github.com/teerapap/grunt-protractor-runner 4 | * 5 | * Copyright (c) 2013 Teerapap Changwichukarn 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = function(grunt) { 12 | 13 | // Project configuration. 14 | grunt.initConfig({ 15 | jshint: { 16 | all: [ 17 | 'Gruntfile.js', 18 | 'tasks/*.js', 19 | '<%= nodeunit.tests %>', 20 | ], 21 | options: { 22 | jshintrc: '.jshintrc', 23 | }, 24 | }, 25 | 26 | // Before generating any new files, remove any previously-created files. 27 | clean: { 28 | tests: ['tmp'], 29 | }, 30 | 31 | // Configuration to be run (and then tested). 32 | protractor: { 33 | options: { 34 | keepAlive: false 35 | }, 36 | testTargetConfigFile: { 37 | configFile:"test/testConf.js", 38 | options: { 39 | webdriverManagerUpdate: true 40 | } 41 | }, 42 | testKeepAliveOnFailedTest: { 43 | configFile:"test/testConf.js", 44 | options: { 45 | keepAlive: true, 46 | args: { 47 | specs:["test/failedTest.js"], 48 | } 49 | } 50 | }, 51 | testArgs1: { 52 | configFile:"test/testConf.js", 53 | options: { 54 | args: { 55 | params: { 56 | number: 1, 57 | bool_true: true, 58 | bool_false: false, 59 | str: "string", 60 | nil: null, // Null is not supported. 61 | obj: { 62 | array: [1, 2, 3], 63 | undef: undefined 64 | } 65 | }, 66 | capabilities: { 67 | 'browserName': 'chrome' 68 | }, 69 | rootElement:"body", 70 | specs:["test/argsTest.js"], 71 | verbose:true 72 | } 73 | } 74 | }, 75 | testArgsSuiteArray: { 76 | configFile:"test/testConf.js", 77 | options: { 78 | args: { 79 | capabilities: { 80 | 'browserName': 'chrome' 81 | }, 82 | suite: ['login', 'logout'], 83 | verbose:true 84 | } 85 | } 86 | }, 87 | testArgSuiteString: { 88 | configFile:"test/testConf.js", 89 | options: { 90 | args: { 91 | capabilities: { 92 | 'browserName': 'chrome' 93 | }, 94 | suite: 'login', 95 | verbose:true 96 | } 97 | } 98 | }, 99 | }, 100 | 101 | // Unit tests. 102 | nodeunit: { 103 | tests: ['test/*_test.js'], 104 | }, 105 | 106 | }); 107 | 108 | // Actually load this plugin's task(s). 109 | grunt.loadTasks('tasks'); 110 | 111 | // These plugins provide necessary tasks. 112 | grunt.loadNpmTasks('grunt-contrib-jshint'); 113 | grunt.loadNpmTasks('grunt-contrib-clean'); 114 | grunt.loadNpmTasks('grunt-contrib-nodeunit'); 115 | 116 | // Whenever the "test" task is run, first clean the "tmp" dir, then run this 117 | // plugin's task(s), then test the result. 118 | grunt.registerTask('test', ['clean', 'protractor', 'nodeunit']); 119 | 120 | // By default, lint and run all tests. 121 | grunt.registerTask('default', ['jshint', 'test']); 122 | 123 | }; 124 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Teerapap Changwichukarn 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # :rotating_light: Warning 2 | 3 | This repository is DEPRECATED and no longer maintained. 4 | 5 | Thank you for all your contributions 6 | 7 | --- 8 | 9 | # grunt-protractor-runner 10 | 11 | [![Build Status](https://travis-ci.org/teerapap/grunt-protractor-runner.svg?branch=master)](https://travis-ci.org/teerapap/grunt-protractor-runner) 12 | 13 | > A Grunt plugin for running [Protractor](https://github.com/angular/protractor) runner. 14 | 15 | ## Getting Started 16 | This plugin requires Grunt `>=0.4.1`. 17 | 18 | For Protractor `5.x.x`, please use version `v5.x.x` of this plugin. 19 | 20 | For Protractor `4.x.x`, please use version `v4.x.x` of this plugin. 21 | 22 | For Protractor `3.x.x`, please use version `v3.x.x` of this plugin. 23 | 24 | For Protractor `2.x.x`, please use version `v2.x.x` of this plugin. 25 | 26 | If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: 27 | 28 | ```shell 29 | npm install grunt-protractor-runner --save-dev 30 | ``` 31 | 32 | This plugin will install `protractor` module locally as a normal dependency. 33 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: 34 | 35 | ```js 36 | grunt.loadNpmTasks('grunt-protractor-runner'); 37 | ``` 38 | 39 | Finally you need a Selenium server. If you don't have one set up already, you can install a local standalone version with this command: 40 | 41 | ```shell 42 | ./node_modules/grunt-protractor-runner/scripts/webdriver-manager-update 43 | ``` 44 | 45 | ## The "protractor" task 46 | 47 | ### Overview 48 | In your project's Gruntfile, add a section named `protractor` to the data object passed into `grunt.initConfig()`. 49 | 50 | ```js 51 | grunt.initConfig({ 52 | protractor: { 53 | options: { 54 | configFile: "node_modules/protractor/example/conf.js", // Default config file 55 | keepAlive: true, // If false, the grunt process stops when the test fails. 56 | noColor: false, // If true, protractor will not use colors in its output. 57 | args: { 58 | // Arguments passed to the command 59 | } 60 | }, 61 | your_target: { // Grunt requires at least one target to run so you can simply put 'all: {}' here too. 62 | options: { 63 | configFile: "e2e.conf.js", // Target-specific config file 64 | args: {} // Target-specific arguments 65 | } 66 | }, 67 | }, 68 | }) 69 | ``` 70 | 71 | ### Options 72 | 73 | #### options.configFile 74 | Type: `String` 75 | Default value: No default value 76 | 77 | A protractor config file. 78 | 79 | #### options.keepAlive 80 | Type: `Boolean` 81 | Default value: `false` (`true` before v1.0.0) 82 | 83 | If true, grunt process continues even if the test fails. This option is useful when using with grunt watch. 84 | If false, grunt process stops when the test fails. 85 | 86 | #### options.noColor 87 | Type: `Boolean` 88 | Default value: `false` 89 | 90 | If true, protractor will not give colored output. 91 | If false, protractor will give colored output, as it does by default. 92 | 93 | #### options.debug 94 | Type: `Boolean` 95 | Default value: `false` 96 | 97 | If true, grunt will pass 'debug' as second argument to protractor CLI to enable node CLI debugging as described in [Protractor Debugging documentation](https://github.com/angular/protractor/blob/master/docs/debugging.md). 98 | 99 | #### options.args 100 | Type: `Object` 101 | Default value: `{}` 102 | 103 | Arguments passed to the command. These arguments can also be supplied via command-line too. Ex.`grunt protractor --specs=specs/some-test.js` or for object options `grunt protractor --cucumberOpts={\"tags\":\"@quick\"}` or `--params='{ "location" : { "href" : "some url" } }'` 104 | 105 | Passing object argument with `--params.xxx.yyy=zzz` is not supported at the moment. If you need this behaviour, please join the discussion in [#148](https://github.com/teerapap/grunt-protractor-runner/pull/148) . 106 | 107 | Supported arguments are below. 108 | 109 | * seleniumAddress `string`: A running selenium address to use 110 | * seleniumServerJar `string`: Location of the standalone selenium server .jar file 111 | * seleniumPort `string`: Optional port for the standalone selenium server 112 | * baseUrl `string`: URL to prepend to all relative paths 113 | * rootElement `string`: Element housing ng-app, if not html or body 114 | * specs `array`: Array of spec files to test. Ex. `["spec1.js","spec2.js"]` 115 | * exclude `array`: Array of files to exclude from testing. Ex. `["spec2.js"]` 116 | * suite `string` or `array`: Suite or Array of suites to run. Ex. `["suite1", "suite2"]` 117 | * includeStackTrace `boolean`: Print stack trace on error 118 | * verbose `boolean`: Print full spec names 119 | * browser `string`: Browser name, e.g. chrome or firefox 120 | * params `object`: Param object to be passed to the test as browser.params 121 | * chromeDriver `string`: Location of chrome driver overridng the property in config file 122 | * directConnect `boolean`: To connect directly to the browser Drivers. This option is only available for Firefox and Chrome. 123 | * sauceUser `string`: Username for a SauceLabs account 124 | * sauceKey `string`: Access Key for a SauceLabs account 125 | * sauceSeleniumAddress `string`: Customize the URL Protractor uses to connect to sauce labs (for example, if you are tunneling selenium traffic through a sauce connect tunnel). Default is `ondemand.saucelabs.com:80/wd/hub` 126 | * capabilities `object`: Capabilities object to be passed to the test, e.g. browserName, platform and version 127 | * framework `string`: Limited support for using mocha as the test framework instead of jasmine. 128 | * frameworkPath `string`: When `framework` is set to `custom`, set this path relative to the config file or absolute 129 | * cucumberOpts `object`: Cucumber framework options object to be passed to the test, e.g. require, tags and format 130 | * mochaOpts `object`: Mocha test framework options object to be passed 131 | * beforeLaunch `string`: You can specify a file containing code to run once configs are read but before any environment setup. This will only run once, and before onPrepare. 132 | * onPrepare `string`: You can specify a file containing code to run once protractor is ready and available, and before the specs are executed. If multiple capabilities are being run, this will run once per capability. 133 | * webDriverProxy `string`: WebDriver proxy configuration to run remote tests 134 | 135 | #### options.output 136 | Type: `String` 137 | Default value: `false` 138 | 139 | The file that the task should output the results to. 140 | 141 | #### options.outputOptions 142 | Type: `Object` 143 | Default value: `{}` 144 | 145 | Options for output file. For details see: [fs.createWriteStream's options](https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options) 146 | 147 | #### options.nodeBin 148 | Type: `String` 149 | Default value: `node` 150 | 151 | Path to the node binary file. Useful if node is not on the PATH. 152 | 153 | #### options.webdriverManagerUpdate 154 | Type: `Boolean` 155 | Default value: `false` 156 | 157 | If true, `webdriver-manager update` will run and install/update selenium driver. 158 | 159 | ## Tests 160 | 161 | Run `npm install` to install dependencies. 162 | 163 | Then run `grunt` or `npm test` to test the module. You will encounter these. 164 | 165 | * Runs unit and e2e tests 166 | * It opens chrome a couple of times without warnings or errors. 167 | * A test task fails but the test process keeps alive and continues to the next test tasks. 168 | 169 | ## Contributing 170 | In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/). 171 | 172 | ## FAQ 173 | 174 | ### Q: Want to global installed protractor? 175 | 176 | This plugin installs `protractor` module locally as a normal dependency. 177 | 178 | In case you want to use the plugin with the global installed protractor command. You can do it with these steps below. 179 | 180 | * Remove local install protractor by `rm -rf node_modules/protractor` 181 | * Install `protractor` globally with `npm install -g protractor` 182 | * Make sure that node can resolve the module with `require()` mechanism. See [Module loading from the global folders](http://nodejs.org/api/modules.html#modules_loading_from_the_global_folders) for more information. 183 | * Run `webdriver-manager update` to install/update selenium driver for global install protractor. 184 | 185 | ### Q: Error: Could not find chromedriver at.... 186 | 187 | You need to install/update selenium webdriver for protractor. 188 | 189 | * Run `webdriver-manager update` or `node scripts/webdriver-manager-update` or `node ./node_modules/protractor/bin/webdriver-manager update` 190 | 191 | ## Release History 192 | 193 | * 5.0.0 194 | * Upgrade `protractor` to version 5 (#185) 195 | 196 | * 4.0.0 197 | * Accept array for `suite` argument (#172) 198 | * Upgrade `protractor` to version 4 (#168) 199 | 200 | * 3.2.0 201 | * Support --frameworkPath in options.args (#155, #156) 202 | * Support `grunt` version `>=0.4.0"` (#154) 203 | * 3.1.0 204 | * Add `options.outputOptions` (#143) 205 | * Support `webDriverProxy` in `options.args` (#147) 206 | * Remove referenceConf.js as default value of options.configFile because it does not exist anymore 207 | * 3.0.0 208 | * Update protractor to version 3 209 | * Update other dependencies including through2 and split to latest version 210 | 211 | * 2.1.2 212 | * Fix boolean parameters in object.args.params (#130) 213 | * Modify unit tests to run nodeunit test faster and after protractor task 214 | * 2.1.1 215 | * Fix EINVAL error when run in git bash shell (#134) 216 | * 2.1.0 217 | * Add `options.webdriverManagerUpdate` option (#125) 218 | * Fix support for object option via command-line (#116) 219 | * 2.0.0 220 | * Upgrade `protractor` to `^2.0.0` (#114) 221 | * `chromeOnly` in `options.args` is deprecated. Replaced by `directConnect` (#114) 222 | * Support `beforeLaunch` and `onPrepare` in `options.args` (#110) 223 | * When one of the tests fails, throw warning instead of fatal error so that grunt can still use --force to continue. (#103) 224 | 225 | * 1.2.1 226 | * Move `split` and `through2` from devDependencies to dependencies (#104) 227 | * 1.2.0 228 | * Add `options.nodeBin` to specify node binary (#96) 229 | * Support --directConnect and --sauceSeleniumAddress in options.args (#95, #101) 230 | * Add options.output (#80) 231 | * Merge README.md PRs (#89, #91) 232 | * Fix plugin test for protractor>=v1.5.0 233 | * Fix TravisCI test 234 | * 1.1.4 235 | * Move `webdriver-manager update` step from problematic postinstall to pretest 236 | * 1.1.3 237 | * Attempt to fix webdriver-manager postinstall problem with webdriver-manager script (#83) 238 | * 1.1.2 239 | * Attempt to fix webdriver-manager path in package.json postinstall 240 | * Add Travis CI build configuration 241 | * 1.1.1 242 | * Run webdriver-manager update on postinstall (#41) 243 | * 1.1.0 244 | * Update protractor to version 1.x.x 245 | * 1.0.1 246 | * Pass specified command line params to the subprocess (#68) 247 | * Make npm test to run and handle interactive debugger by itself (#66) 248 | * Fixed argsTest 249 | * 1.0.0 250 | * Change default value of `options.keepAlive` to false (#50) 251 | 252 | * 0.2.5 253 | * Support --mochaOpts, --suite and --exclude in options.args (#52, #53, #57) 254 | * 0.2.4 255 | * Support --cucumberOpts in options.args (#46) 256 | * 0.2.3 257 | * Temporarily remove automatically download/update webdriver-manager because it fails in some environment such as Windows (#41) 258 | * 0.2.2 259 | * Add `protractor` module as a normal dependency and automatically download/update webdriver with `webdriver-manager` after installed (#29, #39) 260 | * Support --framework in options.args (#36) 261 | * 0.2.1 262 | * Support --capabilities in options.args (#33) 263 | * 0.2.0 264 | * Able to use either local or global install protractor the same way as how `require()` function works (#29) 265 | * Move protractor from `peerDependencies` to `devDependencies`. These changes might break some user modules. (See FAQ above for explanation) (#29) 266 | * 0.1.11 - Support SauceLabs account config in options.args (#27) 267 | * 0.1.10 268 | * Support --chromeOnly in options.args (#23) 269 | * Support options.noColor to turn color off in protractor output (#24) 270 | * 0.1.9 271 | * Able to supply options.args via command-line arguments (#20) 272 | * Fixed merging task-level and target-level options 273 | * 0.1.8 - Support --chromeDriver in options.args (#17) 274 | * 0.1.7 - Support --browser and --params arguments passed to the protractor command using config in options.args (#12) 275 | * 0.1.6 - Change protractor(peerDependencies) to support version to 0.x (#8, #9, #10) 276 | * 0.1.5 - Added `options.debug` (#7) 277 | * 0.1.4 - Change protractor(peerDependencies) to support version to 0.10.x - 0.11.x (#6) 278 | * 0.1.3 - Fixed Windows command 279 | * 0.1.2 - Added keepAlive option. 280 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grunt-protractor-runner", 3 | "description": "A Grunt plugin for running protractor runner.", 4 | "version": "5.0.0", 5 | "homepage": "https://github.com/teerapap/grunt-protractor-runner", 6 | "author": { 7 | "name": "Teerapap Changwichukarn", 8 | "email": "teerapap.c@gmail.com" 9 | }, 10 | "license": "MIT", 11 | "repository": { 12 | "type": "git", 13 | "url": "git://github.com/teerapap/grunt-protractor-runner.git" 14 | }, 15 | "bugs": { 16 | "url": "https://github.com/teerapap/grunt-protractor-runner/issues" 17 | }, 18 | "main": "Gruntfile.js", 19 | "engines": { 20 | "node": ">= 6.9.4" 21 | }, 22 | "scripts": { 23 | "test": "grunt test" 24 | }, 25 | "dependencies": { 26 | "protractor": "^5.0.0", 27 | "split": "~1.0.0", 28 | "through2": "~2.0.0" 29 | }, 30 | "devDependencies": { 31 | "grunt-contrib-jshint": "~0.11.3", 32 | "grunt-contrib-clean": "~0.7.0", 33 | "grunt-contrib-nodeunit": "~0.4.1", 34 | "grunt": "~0.4.1" 35 | }, 36 | "peerDependencies": { 37 | "grunt": ">=0.4.0" 38 | }, 39 | "keywords": [ 40 | "gruntplugin", 41 | "protractor", 42 | "selenium", 43 | "angular", 44 | "angularjs" 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /scripts/webdriver-manager-update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var path = require('path'); 4 | var fork = require('child_process').fork; 5 | 6 | 7 | // '.../node_modules/protractor/lib/protractor.js' 8 | var protractorMainPath = require.resolve('protractor'); 9 | // '.../node_modules/protractor/bin/webdriver-manager' 10 | var webdriverManagerPath = path.resolve(protractorMainPath, '../../bin/webdriver-manager'); 11 | 12 | console.log("webdriver-manager path: " + webdriverManagerPath); 13 | 14 | fork(webdriverManagerPath, ["update"]); 15 | 16 | -------------------------------------------------------------------------------- /tasks/protractor_runner.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-protractor-runner 3 | * https://github.com/teerapap/grunt-protractor-runner 4 | * 5 | * Copyright (c) 2013 Teerapap Changwichukarn 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | var util = require('util'); 12 | var path = require('path'); 13 | var fs = require('fs'); 14 | var split = require('split'); 15 | var through2 = require('through2'); 16 | 17 | module.exports = function(grunt) { 18 | 19 | grunt.registerMultiTask('protractor', 'A grunt task to run protractor.', function() { 20 | 21 | // '.../node_modules/protractor/lib/protractor.js' 22 | var protractorMainPath = require.resolve('protractor'); 23 | // '.../node_modules/protractor/bin/protractor' 24 | var protractorBinPath = path.resolve(protractorMainPath, '../../bin/protractor'); 25 | // '.../node_modules/protractor/bin/webdriver-manager' 26 | var webdriverManagerPath = path.resolve(protractorMainPath, '../../bin/webdriver-manager'); 27 | 28 | // Merge task-specific and/or target-specific options with these defaults. 29 | var opts = this.options({ 30 | keepAlive: false, 31 | noColor: false, 32 | debug: false, 33 | nodeBin: 'node', 34 | args: {}, 35 | output: false, 36 | outputOptions: {}, 37 | webdriverManagerUpdate: false 38 | }); 39 | 40 | // configFile is a special property which need not to be in options{} object. 41 | if (!grunt.util._.isUndefined(this.data.configFile)) { 42 | opts.configFile = this.data.configFile; 43 | } 44 | 45 | grunt.verbose.writeln("Options: " + util.inspect(opts)); 46 | 47 | var keepAlive = opts['keepAlive']; 48 | var strArgs = ["seleniumAddress", "seleniumServerJar", "seleniumPort", "baseUrl", "rootElement", "browser", "chromeDriver", "chromeOnly", "directConnect", "sauceUser", "sauceKey", "sauceSeleniumAddress", "framework", "frameworkPath", "beforeLaunch", "onPrepare", "webDriverProxy"]; 49 | var listArgs = ["specs", "exclude", "suite"]; 50 | var boolArgs = ["includeStackTrace", "verbose"]; 51 | var objectArgs = ["params", "capabilities", "cucumberOpts", "mochaOpts"]; 52 | 53 | var cmd = [protractorBinPath]; 54 | if (!grunt.util._.isUndefined(opts.configFile)){ 55 | cmd.push(opts.configFile); 56 | } 57 | var args = process.execArgv.concat(cmd); 58 | if (opts.noColor){ 59 | args.push('--no-jasmineNodeOpts.showColors'); 60 | } 61 | if (!grunt.util._.isUndefined(opts.debug) && opts.debug === true){ 62 | args.splice(1,0,'debug'); 63 | } 64 | 65 | // Iterate over all supported arguments. 66 | strArgs.forEach(function(a) { 67 | if (a in opts.args || grunt.option(a)) { 68 | args.push('--'+a, grunt.option(a) || opts.args[a]); 69 | } 70 | }); 71 | listArgs.forEach(function(a) { 72 | if (a in opts.args || grunt.option(a)) { 73 | var arg = opts.args[a]; 74 | if (arg instanceof Array) { 75 | arg = arg.join(","); 76 | } 77 | args.push('--'+a, grunt.option(a) || arg); 78 | } 79 | }); 80 | boolArgs.forEach(function(a) { 81 | if (a in opts.args || grunt.option(a)) { 82 | args.push('--'+a); 83 | } 84 | }); 85 | 86 | // Convert [object] to --[object].key1 val1 --[object].key2 val2 .... 87 | objectArgs.forEach(function(a) { 88 | (function convert(prefix, obj, args) { 89 | if (typeof obj === 'string'){ 90 | obj = JSON.parse(obj); 91 | } 92 | for (var key in obj) { 93 | var val = obj[key]; 94 | var type = typeof obj[key]; 95 | if (type === "object") { 96 | if (Array.isArray(val)) { 97 | // Add duplicates --[object].key val1 --[object].key val2 ... 98 | for (var i=0;i -1 && runnerStdOut.indexOf('--cucumberOpts.tags @quick') > -1) { 13 | test.ok(true, 'CucumberOpts test passed!'); 14 | test.done(); 15 | } else { 16 | test.ok(false, 'Could not find cucumberOpts'); 17 | test.done(); 18 | } 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /test/testConf.js: -------------------------------------------------------------------------------- 1 | // A reference configuration file. 2 | exports.config = { 3 | // ----- How to setup Selenium ----- 4 | // 5 | // There are three ways to specify how to use Selenium. Specify one of the 6 | // following: 7 | // 8 | // 1. seleniumServerJar - to start Selenium Standalone locally. 9 | // 2. seleniumAddress - to connect to a Selenium server which is already 10 | // running. 11 | // 3. sauceUser/sauceKey - to use remote Selenium servers via SauceLabs. 12 | 13 | // The location of the selenium standalone server .jar file. 14 | seleniumServerJar: null, 15 | // The port to start the selenium server on, or null if the server should 16 | // find its own unused port. 17 | seleniumPort: null, 18 | // Chromedriver location is used to help the selenium standalone server 19 | // find chromedriver. This will be passed to the selenium jar as 20 | // the system property webdriver.chrome.driver. If null, selenium will 21 | // attempt to find chromedriver using PATH. 22 | chromeDriver: null, 23 | // Additional command line options to pass to selenium. For example, 24 | // if you need to change the browser timeout, use 25 | // seleniumArgs: ['-browserTimeout=60'], 26 | seleniumArgs: [], 27 | 28 | // If sauceUser and sauceKey are specified, seleniumServerJar will be ignored. 29 | // The tests will be run remotely using SauceLabs. 30 | sauceUser: null, 31 | sauceKey: null, 32 | 33 | // The address of a running selenium server. If specified, Protractor will 34 | // connect to an already running instance of selenium. This usually looks like 35 | seleniumAddress: null, 36 | 37 | suites: { 38 | login: 'loginSuiteTest.js', 39 | logout: 'logoutSuiteTest.js' 40 | }, 41 | 42 | // ----- What tests to run ----- 43 | // 44 | // Spec patterns are relative to the location of this config. 45 | specs: [ 46 | 'blankTest.js', 47 | ], 48 | 49 | // ----- Capabilities to be passed to the webdriver instance ---- 50 | // 51 | // For a full list of available capabilities, see 52 | // https://code.google.com/p/selenium/wiki/DesiredCapabilities 53 | // and 54 | // https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js 55 | capabilities: { 56 | 'browserName': 'chrome', 57 | 'chromeOptions': { 58 | 'args': ['no-sandbox','no-default-browser-check','no-first-run','disable-default-apps'] 59 | } 60 | }, 61 | 62 | // A base URL for your application under test. Calls to protractor.get() 63 | // with relative paths will be prepended with this. 64 | baseUrl: 'http://localhost:8000', 65 | 66 | // Selector for the element housing the angular app - this defaults to 67 | // body, but is necessary if ng-app is on a descendant of 68 | rootElement: 'body', 69 | 70 | // A callback function called once protractor is ready and available, and 71 | // before the specs are executed 72 | // You can specify a file containing code to run by setting onPrepare to 73 | // the filename string. 74 | onPrepare: function() { 75 | // At this point, global 'protractor' object will be set up, and jasmine 76 | // will be available. For example, you can add a Jasmine reporter with: 77 | // jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter( 78 | // 'outputdir/', true, true)); 79 | }, 80 | 81 | // ----- Options to be passed to minijasminenode ----- 82 | jasmineNodeOpts: { 83 | // onComplete will be called just before the driver quits. 84 | onComplete: null, 85 | // If true, display spec names. 86 | isVerbose: false, 87 | // If true, print colors to the terminal. 88 | showColors: true, 89 | // If true, include stack traces in failures. 90 | includeStackTrace: true, 91 | // Default time to wait in ms before a test fails. 92 | defaultTimeoutInterval: 30000 93 | } 94 | }; 95 | --------------------------------------------------------------------------------