This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +28
-16
lines changed Expand file tree Collapse file tree 5 files changed +28
-16
lines changed Original file line number Diff line number Diff line change @@ -175,18 +175,10 @@ if (argv.version) {
175175 process . exit ( 0 ) ;
176176}
177177
178- if ( ! argv . disableChecks ) {
179- // Check to see if additional flags were used.
180- let unknownKeys : string [ ] = Object . keys ( argv ) . filter ( ( element : string ) => {
181- return element !== '$0' && element !== '_' && allowedNames . indexOf ( element ) === - 1 ;
182- } ) ;
183-
184- if ( unknownKeys . length > 0 ) {
185- throw new Error (
186- 'Found extra flags: ' + unknownKeys . join ( ', ' ) +
187- ', please use --disableChecks flag to disable the Protractor CLI flag checks.' ) ;
188- }
189- }
178+ // Check to see if additional flags were used.
179+ argv . unknownFlags_ = Object . keys ( argv ) . filter ( ( element : string ) => {
180+ return element !== '$0' && element !== '_' && allowedNames . indexOf ( element ) === - 1 ;
181+ } ) ;
190182
191183/**
192184 * Helper to resolve comma separated lists of file pattern strings relative to
Original file line number Diff line number Diff line change @@ -595,7 +595,13 @@ export interface Config {
595595 */
596596 ng12Hybrid ?: boolean ;
597597
598- seleniumArgs ?: Array < any > ;
598+ /**
599+ * Protractor will exit with an error if it sees any command line flags it doesn't
600+ * recognize. Set disableChecks true to disable this check.
601+ */
602+ disableChecks ?: boolean ;
603+
604+ seleniumArgs ?: any [ ] ;
599605 jvmArgs ?: string [ ] ;
600606 configDir ?: string ;
601607 troubleshoot ?: boolean ;
@@ -607,4 +613,5 @@ export interface Config {
607613 frameworkPath ?: string ;
608614 elementExplorer ?: any ;
609615 debug ?: boolean ;
616+ unknownFlags_ ?: string [ ] ;
610617}
Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ Requirements
3737
3838- ` runner.runTestPreparer ` must be called after the framework has been
3939 initialized but before any spec files are run. This function returns a
40- promise which should be waited on before executing tests.
40+ promise which should be waited on before executing tests. The framework should
41+ also pass an array of extra command line flags it accepts, if any.
4142
4243- ` runner.getConfig().onComplete ` must be called when tests are finished.
4344 It might return a promise, in which case ` exports.run ` 's promise should not
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import * as util from 'util';
66import { ProtractorBrowser } from './browser' ;
77import { Config } from './config' ;
88import { buildDriverProvider , DriverProvider } from './driverProviders' ;
9+ import { ConfigError } from './exitCodes' ;
910import { Logger } from './logger' ;
1011import { Plugins } from './plugins' ;
1112import { protractor } from './ptor' ;
@@ -79,10 +80,21 @@ export class Runner extends EventEmitter {
7980 /**
8081 * Executor of testPreparer
8182 * @public
83+ * @param {string[]= } An optional list of command line arguments the framework will accept.
8284 * @return {q.Promise } A promise that will resolve when the test preparers
8385 * are finished.
8486 */
85- runTestPreparer ( ) : q . Promise < any > {
87+ runTestPreparer ( extraFlags ?: string [ ] ) : q . Promise < any > {
88+ let unknownFlags = this . config_ . unknownFlags_ || [ ] ;
89+ if ( extraFlags ) {
90+ unknownFlags = unknownFlags . filter ( ( f ) => extraFlags . indexOf ( f ) === - 1 ) ;
91+ }
92+ if ( unknownFlags . length > 0 && ! this . config_ . disableChecks ) {
93+ throw new ConfigError (
94+ logger ,
95+ 'Found extra flags: ' + unknownFlags . join ( ', ' ) +
96+ ', please use --disableChecks flag to disable the Protractor CLI flag checks. ' ) ;
97+ }
8698 return this . plugins_ . onPrepare ( ) . then ( ( ) => {
8799 return helper . runFilenameOrFn_ ( this . config_ . configDir , this . preparer_ ) ;
88100 } ) ;
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ var checkLogs = function(output, messages) {
2121
2222runProtractor = spawn ( 'node' ,
2323 [ 'bin/protractor' , 'example/conf.js' , '--foobar' , 'foobar' ] ) ;
24- output = runProtractor . stderr . toString ( ) ;
24+ output = runProtractor . stdout . toString ( ) ;
2525messages = [ 'Error: Found extra flags: foobar' ] ;
2626checkLogs ( output , messages ) ;
2727
You can’t perform that action at this time.
0 commit comments