-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Protractor CLI rejects cucumberOpts
as invalid
#3978
Comments
The goal of the flag checks is to help catch when people misspell a flag name, so ignoring additional keys would defeat the purpose. However, there should be a way for protractor-cucumber-framework to add to the whitelist, we can work on that. |
I guess there could be an API to allow plugin authors to register additional commands perhaps? |
@jan-molak This is strange you should not face this issue. Are you sure you are not passing As you see protractor's config interface was recently updated to support any optional key i.e. it allows us to use But since you are passing For your reference also pls check protractor-cookbook protractor-typescript-cucumber example which was recently upgraded to Protractor 5.0 with no issues. |
Thanks @igniteram, I didn't realise the behaviour is different when the option is specified on the command line. Now that you pointed that out it might be relevant that I'm doing both:
A complete example to demonstrate the behaviour I'm seeing would be this: // protractor.conf.js
exports.config = {
seleniumServerJar: path.resolve(node_modules, 'protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-2.53.1.jar'),
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
specs: [ 'features/**/*.feature' ],
cucumberOpts: {
require: [
'features/**/*.ts'
],
format: 'pretty',
compiler: 'ts:ts-node/register',
}
}; // package.json
{
// ...
"scripts": {
"pree2e": "npm run webdriver:update -- --standalone",
"e2e": "protractor ./protractor.conf.js",
"e2e-single": "protractor ./protractor.conf.js --cucumberOpts.name",
"webdriver-manager": "webdriver-manager",
"webdriver:update": "npm run webdriver-manager update",
// ...
}
} Now, although running
I suppose this means that the issue still stands, but thanks to your suggestion it can be narrowed down to the CLI rather than the config. Thanks! |
@jan-molak This is expected behaviour! since protractor 5.0, there is a check for unidentified command line flags, i.e. it would throw the above error if you use any flag which is not part of protractor's command line options which can be found here . You could see that
Now your script should run successfully, The job of In the next version of protractor you would get a better error message for these scenarios. I hope this clarifies your query! |
Thank you for getting back to me so quickly! If I may make a suggestion, perhaps allowing plugin authors to register additional flags for the CLI and configuration options for the This way the white list we discussed earlier could stay as it is, but optionally get expanded via plugins. Looking forward to hearing your thoughts! |
Expanding the white list via plugin api should be a viable option in future. @cnishina what are your thoughts on it? you are the right person here 😄 |
…ng protractor with --cucubmerOpts As per our conversation at angular/protractor#3978
Fix for #3978. Our initial plan to allow setting --disableChecks with an environment variable is insufficient, since the custom framework isn't even require()'d until after the config is parsed. This moves the unknown flag check into the runner, and gives frameworks a way to specify extra flags they accept.
There might be a better way to do this that we could do in the future. In the meantime, #3994 will allow frameworks to specify extra flags that they accept in the call to This should go out in Protractor 5.1 |
Awesome, thanks for your help @mgiambalvo 👍 |
This change adds support for using Serenity/JS with Protractor 5.0.0, 5.1.0 and 5.1.1: - `ProtractorNotifier` deals with Protractor 5.1.0 requirement for test frameworks to invoke `runner.afterEach` after every test, so that the browser is correctly restarted between the tests. See angular/protractor#4087 - `TestFrameworkDetector` registers `mochaOpts` and `cucumberOpts` as valid command line options, benefiting from angular/protractor#3994 and dealing with a bug introduced in Protractor 5.0.0, which prevents command line arguments from being passed on to custom test frameworks. See angular/protractor#3978 - Updated the examples and documentation to work with Protractor 5.1.x - Enables #18 Related issues: angular/protractor#3978 angular/protractor#3994 angular/protractor#4087 #18
…3994) Fix for angular#3978. Our initial plan to allow setting --disableChecks with an environment variable is insufficient, since the custom framework isn't even require()'d until after the config is parsed. This moves the unknown flag check into the runner, and gives frameworks a way to specify extra flags they accept.
@mgiambalvo Is there currently any way for me to plug these into the call to runTestPreparer to get rid of the warning? |
I'm facing the same thing as @AlexMarchini It would be good to have a way to tell protractor those are to be expected. |
This feature is already available in protractor, Since v5.1 you have 2 options-
Please check the config.ts interface on how this could be set.
it is also available in config.ts |
Hi @igniteram, I have the same issue but my problem is that I have a lot of arguments in the cucumberOpts something like that:
is possible to pass all those params by the cli at the same time?. Also I'm not using typeScripts |
Hi @igniteram, I tried to run this:
but the steps were not found by protractor. |
Where can I adjust the default cucumber timeout? I haven't found a list of all available cucumberOpts. |
You can't adjust it through the command line. See the CucumberJS timeouts-docs to adjust this. Maybe if you create something custom you can add it like for example using yargs and do something like this // You CucumberJS timeout file that you load through your `cucumberOpts.require` in your
// Protractor conf
var {defineSupportCode} = require('cucumber');
// Add yargs
var argv = require('yargs').argv
defineSupportCode(function({setDefaultTimeout}) {
// Then add the property `defaultTimeout` that will be passed through the cli with
// npm run protractor -- --defaultTimeout=60000
setDefaultTimeout(argv.defaultTimeout);
}); |
Warning goes away when upgrading protractor-cucumber-framework from 4.2.0 to 5.0.0 on my machine. So yes! closed. |
Hello there!
It looks like the whitelist defined in the
cli.ts
rejects thecucumberOpts
key which theprotractor-cucumber-framework
uses.6.9.4
5.0.0
Running protractor with the below config file results in this output:
I guess there are several ways to resolve this issue:
--disableChecks
switch (that's more of a workaround, though)cucumberOpts
, which allows people to run their cucumber tests same as they used to, but requires the Protractor Team to amend the whitelist whenever a new framework comes along or changes the way it's configured (which breaks "half of SOLID" ;-))Looking forward to hearing your thoughts!
Jan
The text was updated successfully, but these errors were encountered: