Description
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