user2207839
user2207839

Reputation: 77

Getting the error Cannot read property 'length' of undefined when I run my protractor tests with cucumber framework

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?

Upvotes: 3

Views: 2492

Answers (2)

chfw
chfw

Reputation: 4592

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.

Upvotes: 0

vivascau
vivascau

Reputation: 622

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

Upvotes: 3

Related Questions