Cucumber-js: What happened to the "cucumberOpts" parameter? Is that no longer supported?

Created on 6 Jun 2017  路  5Comments  路  Source: cucumber/cucumber-js

This issue is a continuation of this https://github.com/angular/protractor/issues/4311. Where I'm discussing the changes on syntax about how to use protractor to execute Cucumberjs scripts.

As requested by @wswebcreation https://github.com/wswebcreation, I closed that other issue and opened a new one here.

So, my last comment was this....

The last record I have of a successful execution was on 12 May 2017, 14:03. Precisely the date in your document.

Your example about tags is very simplistic... how then should I call for 3 tags, two that must be executed and one that is ignored. Before May 12, this used to work fine, but now it doesn't:

protractor ./FM_IntTest_UI_conf.js --disableChecks [email protected] --params.login.passw=mypassword --cucumberOpts.tags ~@ignore --cucumberOpts.tags @smoke,@sprint

Your document says now it should be like this, but doesn't work, returns same error message I submitted with the "ticket".

protractor ./FM_IntTest_UI_conf.js --disableChecks [email protected] --params.login.passw=mypassword --cucumberOpts.tags '@smoke or @rt' --cucumberOpts.tags 'not @ignore'

Error: Error: more than one config file specified
at C:\Users\echavez\AppData\Roaming\npm\node_modules\protractor\built\cli.js:155:15
at C:\Users\echavez\AppData\Roaming\npm\node_modules\protractor\node_modules\optimist\index.js:307:21
at Array.forEach (native)
at parseArgs (C:\Users\echavez\AppData\Roaming\npm\node_modules\protractor\node_modules\optimist\index.js:305:16)
at Object.Argv.self.parse (C:\Users\echavez\AppData\Roaming\npm\node_modules\protractor\node_modules\optimist\index.js:140:16)
at Object. (C:\Users\echavez\AppData\Roaming\npm\node_modules\protractor\built\cli.js:158:21)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)

I can see in the Cucumber document that also the coding syntax for step definition changed? Why making it more complicated now? Because with the new syntax, I must group steps by scenarios. But there are some steps that are repeated in several scenarios, thus repeating code on each scenario? I will end up with redundancies in my code. Why?

Here's a snippet of what I have NOW in my test.spec.js file:

this.Given('I am testing my Widget Application', function (callback) {
    edirp.edirejectwidgetlink.click().then(function(){ 
        callback();
    }).catch(function(reason) {
        console.log('ERROR: Widget button not found');
        callback(reason);
    });
});

this.When('There are records in the Widget List', function() {
    edirp.edigetrow.count().then(function(cnt){
        if(cnt>0){
            return recordsFound = cnt;
        }else{
            return recordsFound = 0;
        }
    });
});


this.Then('Header name of the Widget List is '(.+)'', function(header, callback) {
    expect(po.headertext.getText()).to.eventually.equal(header).then(function(){ 
        callback();
    }).catch(function(reason) {
        console.log('Warning: Incorrect Text.');
        callback(reason);
    });
});

Here's a snippet of what is proposed as an "update"... for me is a DOWNGRADE:

var seleniumWebdriver = require('selenium-webdriver');
var {defineSupportCode} = require('cucumber');

defineSupportCode(function({Given, When, Then}) {
  Given('I am testing my Widget Application', function (callback) {
    edirp.edirejectwidgetlink.click().then(function(){ 
        callback();
    }).catch(function(reason) {
        console.log('ERROR: Widget button not found');
        callback(reason);
    });

  When('There are records in the Widget List', function() {
    edirp.edigetrow.count().then(function(cnt){
        if(cnt>0){
            return recordsFound = cnt;
        }else{
            return recordsFound = 0;
        }
    });
  Then('Header name of the Widget List is '(.+)'', function(header, callback) {
    expect(po.headertext.getText()).to.eventually.equal(header).then(function(){ 
        callback();
    }).catch(function(reason) {
        console.log('Warning: Incorrect Text.');
        callback(reason);
    });
});

If the scenario has several Given, When, Then... do those have to be enumerated here, like this?:
defineSupportCode(function({Given, And, And, When, And, And, Then, And, And, And}) {

If that's is true... So now, if I want to use again the step "When There are records in the EDI-Rejects Widget" in another scenario in my feature, do I need to code all the function again?

All I need are answers with arguments. Don't take it personally.

All 5 comments

If the scenario has several Given, When, Then... do those have to be enumerated here, like this?:
defineSupportCode(function({Given, And, And, When, And, And, Then, And, And, And}) {

No. Given, When, and Then are functions that you can call multiple times (similar to this.Given, etc from 1.x). And is not a function. You can see all the functions passed by defineSupportCode in the API Reference which is linked to from the README.md

I can see in the Cucumber document that also the coding syntax for step definition changed?

See https://github.com/cucumber/cucumber-js/issues/679

Why making it more complicated now? Because with the new syntax, I must group steps by scenarios.

That isn't true

Thanks I'll check that out!

@charlierudolph Tnx for explaining!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  7Comments

jfstephe picture jfstephe  路  4Comments

lamartire picture lamartire  路  6Comments

kozhevnikov picture kozhevnikov  路  6Comments

dblooman picture dblooman  路  7Comments