This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree 5 files changed +28
-16
lines changed
5 files changed +28
-16
lines changed Original file line number Diff line number Diff line change @@ -175,18 +175,10 @@ if (argv.version) {
175
175
process . exit ( 0 ) ;
176
176
}
177
177
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
+ } ) ;
190
182
191
183
/**
192
184
* 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 {
595
595
*/
596
596
ng12Hybrid ?: boolean ;
597
597
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 [ ] ;
599
605
jvmArgs ?: string [ ] ;
600
606
configDir ?: string ;
601
607
troubleshoot ?: boolean ;
@@ -607,4 +613,5 @@ export interface Config {
607
613
frameworkPath ?: string ;
608
614
elementExplorer ?: any ;
609
615
debug ?: boolean ;
616
+ unknownFlags_ ?: string [ ] ;
610
617
}
Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ Requirements
37
37
38
38
- ` runner.runTestPreparer ` must be called after the framework has been
39
39
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.
41
42
42
43
- ` runner.getConfig().onComplete ` must be called when tests are finished.
43
44
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';
6
6
import { ProtractorBrowser } from './browser' ;
7
7
import { Config } from './config' ;
8
8
import { buildDriverProvider , DriverProvider } from './driverProviders' ;
9
+ import { ConfigError } from './exitCodes' ;
9
10
import { Logger } from './logger' ;
10
11
import { Plugins } from './plugins' ;
11
12
import { protractor } from './ptor' ;
@@ -79,10 +80,21 @@ export class Runner extends EventEmitter {
79
80
/**
80
81
* Executor of testPreparer
81
82
* @public
83
+ * @param {string[]= } An optional list of command line arguments the framework will accept.
82
84
* @return {q.Promise } A promise that will resolve when the test preparers
83
85
* are finished.
84
86
*/
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
+ }
86
98
return this . plugins_ . onPrepare ( ) . then ( ( ) => {
87
99
return helper . runFilenameOrFn_ ( this . config_ . configDir , this . preparer_ ) ;
88
100
} ) ;
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ var checkLogs = function(output, messages) {
21
21
22
22
runProtractor = spawn ( 'node' ,
23
23
[ 'bin/protractor' , 'example/conf.js' , '--foobar' , 'foobar' ] ) ;
24
- output = runProtractor . stderr . toString ( ) ;
24
+ output = runProtractor . stdout . toString ( ) ;
25
25
messages = [ 'Error: Found extra flags: foobar' ] ;
26
26
checkLogs ( output , messages ) ;
27
27
You can’t perform that action at this time.
0 commit comments