3
votes

I recently started working on protractor using cucumber framework. I created my first sample test of my own and got the below error

[launcher] Running 1 instances of WebDriver [launcher] Error: TypeError: Cannot read property 'length' of undefined at Function.Configuration (/usr/local/lib/node_modules/cucumber/lib/cucumber/cli/configuration.js:8:11) at /usr/local/lib/node_modules/protractor/lib/frameworks/cucumber.js:148:39 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 doNTCallback0 (node.js:417:9) [launcher] Process exited with error code 100

I re-installed cucumber but still I get the error. Can someone help me on how to fix this issue?

2
Can you update your question with the code where the error is showing up? Your error clearly states that you are using .length on an undefined variable. ThanksGirish Sortur
Hi, this is my conf file for which i am getting the above error exports.config = { chromeDriver:'/usr/local/lib/node_modules/protractor/selenium/chromedriver', seleniumAddress: 'localhost:4444/wd/hub', framework: 'cucumber', capabilities: { browserName: 'chrome' }, specs: ['testrun.feature'], cucumberOpts: { require: ['testrun_steps.js'], } }user2207839

2 Answers

3
votes

It might be a problem with the versions you are using.

I kind of had the same issue when using protractor v2.5.1 and cucumber v0.9.2. (run protractor --version to check)

Try changing your package.json file to have "cucumber": "~0.7.0", and run again npm install.

As per Anmol's response:

npm remove cucumber npm install --save-dev [email protected]

If you are using protractor v3.x see here https://angular.github.io/protractor/#/frameworks#using-cucumber

0
votes

I got the same problem when upgraded my cucumber to newer version 0.9.5:

Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
[launcher] Error: TypeError: Cannot read property 'length' of undefined

so, it turns out that protractor does not embed cucumber any more and I have to add one line in my package.json:

"protractor-cucumber-framework": "^0.6.0",

And then update "framework" in my protractor.conf as:

"framework": "custom", // "cucumber"

And then in my protractor.conf, add:

frameworkPath: "node_modules/protractor-cucumber-framework",

then run npm install, the TypeError shall disappear when you run protractor test again.