Protractor: Cucumber error appears while debugging protractor tests in visual studio code, but in the run mode everything works fine

Created on 9 Apr 2018  ·  3Comments  ·  Source: angular/protractor

Greetings Team,

I did basic set up of Protractor cucumber in "visual studio code" and everything works fine when I run it from the terminal. However when I debug it through visual studio code it gives me version error. I have not installed Cucumber globally. I installed it through npm install in the local directory but still the error message says that I am keeping two different versions. How come it be possible?

This error message should also come in the run mode why is it coming only in the debug mode. Please see below error.

**[18:34:15] I/launcher - Running 1 instances of WebDriver
logger.js:158
[18:34:15] I/local - Starting selenium standalone server...
logger.js:158
[18:34:16] I/local - Selenium standalone server started at http://10.12.2.155:60837/wd/hub
logger.js:158
Unhandled rejection Error:
debuggability.js:868
You appear to be executing an install of cucumber (most likely a global install)
that is different from your local install (the one required in your support files).
For cucumber to work, you need to execute the same install that is required in your support files.
Please execute the locally installed version to run your tests.
Executed Path: D:\Prog Test\protractor-cucumber-master\node_modules\cucumber\lib\index.js
Local Path: d:\Prog Test\protractor-cucumber-master\node_modules\cucumber\lib\index.js

at D:\Prog Test\protractor-cucumber-master\node_modules\cucumbersrc\cli\install_validator.js:17:11
at Generator.next ()
at Generator.tryCatcher (D:\Prog Test\protractor-cucumber-master\node_modules\bluebird\js\release\util.js:16:23)
at PromiseSpawn._promiseFulfilled (D:\Prog Test\protractor-cucumber-master\node_modules\bluebird\js\release\generators.js:97:49)
at Promise._settlePromise (D:\Prog Test\protractor-cucumber-master\node_modules\bluebird\js\release\promise.js:574:26)
at Promise._settlePromise0 (D:\Prog Test\protractor-cucumber-master\node_modules\bluebird\js\release\promise.js:614:10)
at Promise._settlePromises (D:\Prog Test\protractor-cucumber-master\node_modules\bluebird\js\release\promise.js:693:18)
at Async._drainQueue (D:\Prog Test\protractor-cucumber-master\node_modules\bluebird\js\release\async.js:133:16)
at Async._drainQueues (D:\Prog Test\protractor-cucumber-master\node_modules\bluebird\js\release\async.js:143:10)
at Immediate.Async.drainQueues (D:\Prog Test\protractor-cucumber-master\node_modules\bluebird\js\release\async.js:17:14)
at runCallback (timers.js:794:20)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)
[18:34:25] E/launcher - BUG: launcher exited with 1 tasks remaining
logger.js:158**

_Below are the dependencies of package.json which got installed after running "npm install"_

`{
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-register": "^6.26.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"cucumber": "^3.2.1",
"cucumber-html-report": "^0.6.2",
"cucumber-html-reporter": "^3.0.4",
"cucumberjs-allure-reporter": "^1.0.3",
"mkdirp": "^0.5.1",
"protractor": "^5.2.0",
"protractor-cucumber-framework": "^4.1.1"
},

}
`

Most helpful comment

You need to specify the cwd in your .vscode/launch.json as following:

"cwd": "${workspaceRoot}"

"configurations": [
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "cwd": "${workspaceRoot}",
        "program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
        "stopOnEntry": false,
        "args": [
            "${workspaceRoot}/config/config.js"
        ],
    }
]

All 3 comments

You need to specify the cwd in your .vscode/launch.json as following:

"cwd": "${workspaceRoot}"

"configurations": [
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "cwd": "${workspaceRoot}",
        "program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
        "stopOnEntry": false,
        "args": [
            "${workspaceRoot}/config/config.js"
        ],
    }
]

I see the same problem with Protractor and VSCode.
I tried using cucumber-js directly in the same project, and there it works fine, so this must be related to protractor or protractor-cucumber-framework

Thank you for posting this! I found it over a year later and the 'cwd' fix worked for me.

Was this page helpful?
0 / 5 - 0 ratings