From 0a0c0d83026376c44c8a7472412230c1ad93ccee Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Mon, 23 Feb 2015 10:34:58 -0800 Subject: [PATCH] feat(spec): add spec argument to the protractor config, allows to filter tests to run Closes #695 --- README.md | 2 +- protractor-shared.js | 30 ++++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 70ac9f36db..e914bceaf8 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ to the preprocessor and run the tests without exiting karma 4. `protractor protractor-dart2js.conf.js`: Dart2JS e2e tests Angular specific command line options when running protractor: -`protractor protractor-{js|dart2js}-conf.js --ng-help` + - `protractor protractor-{js|dart2js}-conf.js --ng-help` ### Performance tests diff --git a/protractor-shared.js b/protractor-shared.js index 55e5f67679..9c25b853f5 100644 --- a/protractor-shared.js +++ b/protractor-shared.js @@ -10,7 +10,7 @@ var argv = require('yargs') type: 'boolean' }, 'force-gc': { - describe: 'force gc', + describe: 'force gc.', default: false, type: 'boolean' }, @@ -19,8 +19,12 @@ var argv = require('yargs') default: false }, 'browsers': { - describe: 'preconfigured browsers that should be used', + describe: 'comma separated list of preconfigured browsers to use', default: 'ChromeDesktop' + }, + 'spec': { + describe: 'comma separated file patterns to test', + default: false } }) .help('ng-help') @@ -95,6 +99,21 @@ var BROWSER_CAPS = { } }; +var getBenchmarkFiles = function (benchmark, spec) { + var specFiles = []; + var perfFiles = []; + if (spec.length) { + spec.split(',').forEach(function (name) { + specFiles.push('dist/js/cjs/**/e2e_test/' + name) + perfFiles.push('dist/js/cjs/**/e2e_test/' + name) + }); + } else { + specFiles.push('dist/js/cjs/**/e2e_test/**/*_spec.js'); + perfFiles.push('dist/js/cjs/**/e2e_test/**/*_perf.js'); + } + return benchmark ? perfFiles : specFiles.concat(perfFiles); +}; + var config = exports.config = { // Disable waiting for Angular as we don't have an integration layer yet... // TODO(tbosch): Implement a proper debugging API for Ng2.0, remove this here @@ -110,12 +129,7 @@ var config = exports.config = { } }, - specs: argv['benchmark'] ? [ - 'dist/js/cjs/**/e2e_test/**/*_perf.js' - ] : [ - 'dist/js/cjs/**/e2e_test/**/*_spec.js', - 'dist/js/cjs/**/e2e_test/**/*_perf.js' - ], + specs: getBenchmarkFiles(argv['benchmark'], argv['spec']), exclude: [ 'dist/js/cjs/**/node_modules/**',