Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using Protractor 2.1.0 with CucumberJS 0.4.9 #342

Closed
aristarkhartemiy opened this issue Jun 4, 2015 · 13 comments
Closed

Error using Protractor 2.1.0 with CucumberJS 0.4.9 #342

aristarkhartemiy opened this issue Jun 4, 2015 · 13 comments

Comments

@aristarkhartemiy
Copy link

CucumberJS 0.4.9 is supported by Protractor 2.0.0. However, is CucumberJS 0.4.9 supported by Protractor 2.1.0?

I'm experiencing trouble upgrading to Protractor 2.1 from Protractor 2.0 in my project which uses CucumberJS 0.4.9. I suspect it's an issue with the use of Protractor 2.1.0 and CucumberJS 0.4.9.

When I edit the package.json to downgrade to Protractor 2.0.0, and reinstall the node packages, the issue is resolved. What's causing the error in Protractor 2.1.0 with CucumberJS 0.4.9?

My project files and their contents are listed below:

/path/to/myproject/conf.js

exports.config = {
  specs: [
    'features/*.feature'
  ],
  multiCapabilities: [
    {
      'browserName': 'chrome'
    }
  ],
  framework: 'cucumber',
  cucumberOpts: {
    require: 'features/stepDefinitions.js',
    format: 'summary'
  }
};

/path/to/myproject/features/demo.feature

Feature: Refund item

  Scenario: Jeff returns a faulty microwave
    Given Jeff has bought a microwave for $100
    And he has a receipt
    When he returns the microwave
    Then Jeff should be refunded $100

/path/to/myproject/features/stepDefinitions.js

module.exports = function() {
  this.Given(/^Jeff has bought a microwave for \$(\d+)$/, function (arg1, callback) {
    // Write code here that turns the phrase above into concrete actions
    callback.pending();
  });

  this.Given(/^he has a receipt$/, function (callback) {
    // Write code here that turns the phrase above into concrete actions
    callback.pending();
  });

  this.When(/^he returns the microwave$/, function (callback) {
    // Write code here that turns the phrase above into concrete actions
    callback.pending();
  });

  this.Then(/^Jeff should be refunded \$(\d+)$/, function (arg1, callback) {
    // Write code here that turns the phrase above into concrete actions
    callback.pending();
  });
};

/path/to/myproject/package.json

{
  "name": "strato-remake",
  "version": "1.0.0",
  "description": "",
  "main": "conf.js",
  "dependencies": {
  },
  "devDependencies": {
    "cucumber": "0.4.9",
    "protractor": "2.1.0"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "MIT"
}

When the node packages are installed, and Protractor is run:

$ npm install
$ $(npm bin)/webdriver-manager update
$ $(npm bin)/webdriver-manager start
$ $(npm bin)/protractor conf.js

The following error is printed to the terminal:

Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.1.115:35156/wd/hub
[launcher] Error: TypeError: Cannot read property 'apply' of undefined
  at formatter.handleBeforeFeatureEvent (/path/to/myproject/node_modules/protractor/lib/frameworks/cucumber.js:83:41)
  at /path/to/myproject/node_modules/protractor/lib/frameworks/cucumber.js:153:15
  at Function.promise (/path/to/myproject/node_modules/protractor/node_modules/q/q.js:650:9)
  at /path/to/myproject/node_modules/protractor/lib/frameworks/cucumber.js:147:14
  at _fulfilled (/path/to/myproject/node_modules/protractor/node_modules/q/q.js:797:54)
  at self.promiseDispatch.done (/path/to/myproject/node_modules/protractor/node_modules/q/q.js:826:30)
  at Promise.promise.promiseDispatch (/path/to/myproject/node_modules/protractor/node_modules/q/q.js:759:13)
  at /path/to/myproject/node_modules/protractor/node_modules/q/q.js:525:49
  at flush (/path/to/myproject/node_modules/protractor/node_modules/q/q.js:108:17)
  at process._tickCallback (node.js:355:11)
[launcher] Process exited with error code 100

However, if I edit the package.json to downgrade to Protractor 2.0.0, and install the node packages again:

"devDependencies": {
  "cucumber": "0.4.9",
  "protractor": "2.0.0"
},

It then works when I run Protractor:

$ $(npm bin)/protractor conf.js

Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.1.115:38912/wd/hub
1 scenario (1 pending)
4 steps (1 pending, 3 skipped)
Shutting down selenium standalone server.
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 passed
@jbpros
Copy link
Member

jbpros commented Jun 5, 2015

Looks like a bug in protractor:

See https://github.com/angular/protractor/blob/2.1.0/lib/frameworks/cucumber.js#L82

I think if (typeof originalHandleAfterScenarioEvent == 'function') { should be if (typeof originalHandleBeforeScenarioEvent == 'function') { instead.

@jbpros jbpros closed this as completed Jun 5, 2015
jbpros added a commit to jbpros/protractor that referenced this issue Jun 5, 2015
jbpros added a commit to jbpros/protractor that referenced this issue Jun 5, 2015
@jbpros
Copy link
Member

jbpros commented Jun 5, 2015

PR opened on Protractor.

sjelin pushed a commit to angular/protractor that referenced this issue Jun 8, 2015
@jbpros
Copy link
Member

jbpros commented Jun 9, 2015

@aristarkhartemiy FYI my PR on protractor has been merged.

Is everything fine now?

@aristarkhartemiy
Copy link
Author

Thank you. It works.

@bmsoko
Copy link

bmsoko commented Oct 26, 2015

@aristarkhartemiy Hi! can you please help me using protractor+cucumber?
I've a non-angular app, and the thing is that I had completed all installation, but when I run
protractor conf.js

I'm getting this error:

$ protractor conf.js
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.0.104:57029/wd/hub
[launcher] Error: TypeError: undefined is not a function
    at /usr/local/lib/node_modules/protractor/lib/frameworks/cucumber.js:150:36
    at Function.promise (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:650:9)
    at /usr/local/lib/node_modules/protractor/lib/frameworks/cucumber.js:147:14
    at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:797:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:826:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:759:13)
    at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:525:49
    at flush (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:355:11)
[launcher] Process exited with error code 100

I've this structure:
structure1

My config.js

exports.config = {
    specs: [
        'features/*.feature'
    ],
    multiCapabilities: [
        {
            'browserName': 'chrome'
        }
    ],
    framework: 'cucumber',
    cucumberOpts: {
        require: 'features/carouselsteps.js',
        format: 'summary'
    }
};

I guess that you run your test by protractor config.js right??

PLEASE HELP!

EDIT:
This is the cucumber lib in /usr/local/lib/node_modules/protractor/lib/frameworks/cucumber.js:150:36
cucumberjs

@charlierudolph
Copy link
Member

In 0.8.0 when we added support for multiple formatters, the function changed from getFormatter to getFormatters (which returns an array).

@bmsoko
Copy link

bmsoko commented Oct 26, 2015

@charlierudolph Thanks for your reply! I've forced to use 0.8.0, and I had installed globally Protractor and cucumber, but, I keep getting the same behavior, seems that some how its trying to use locallly Cucumber... at /usr/local/lib/node_modules/protractor/lib/frameworks/cucumber.js:150:36 and not the module, is that correct?

Shouldn't it be looking for cucumber module? where/how do I force to look into it?

Thanks!

@charlierudolph
Copy link
Member

The current version of protractor is using cucumber 0.6.0. Protractor needs to be updated to be compatible with the new version of cucumber.

@bmsoko
Copy link

bmsoko commented Oct 26, 2015

@charlierudolph OK! I had downgraded to 0.6.0, the getFormatter is not throwing error, but still getting the same behavior, Sorry to ask to you again, but is there a way I can force to use the cucumber module instead of the local library? because, of what I wrote before, in the error it seems that it wants to use the module inside protractor libraries instead of the cucumber module.
I've also downgraded to Protractor 2.0.0 (same error), do you know of any incompatibility between both? or do you know which are the last matching version of them to get this working?

Thanks a lot for your time!

@charlierudolph
Copy link
Member

Protractor uses the cucumber module and protractor/lib/frameworks/cucumber.js is there glue code to interface with the cucumber module. I am uncertain of the compatibility and which versions work.

@bmsoko
Copy link

bmsoko commented Oct 26, 2015

@charlierudolph thanks! I just saw this issue 2634 which I had commented as well!

@ravioshankar
Copy link

I am also facing same issue

@lock
Copy link

lock bot commented Oct 25, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants