cucumberwebdriver-io

Error: The "from" argument must be of type string. Received undefined


I am using webdriverIO v7 (latest stable version) and cucumber.
I get that error: Error: The "from" argument must be of type string. Received undefined
This is the stack trace:

2021-04-08T18:29:37.403Z ERROR @wdio/runner: TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined
    at validateString (internal/validators.js:120:11)
    at Object.relative (path.js:437:5)
    at getDefinitionLineAndUri (C:\my-project\node_modules\cucumber\lib\support_code_library_builder\build_helpers.js:184:27)
    at buildStepDefinitionConfig (C:\my-project\node_modules\cucumber\lib\support_code_library_builder\build_helpers.js:124:7)
    at SupportCodeLibraryBuilder.defineStep (C:\my-project\node_modules\cucumber\lib\support_code_library_builder\index.js:51:79)
    at Object.<anonymous> (C:\my-project\src\step_definitions\/accountSummary_steps.js:6:1)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Module._compile (C:\my-project\node_modules\pirates\lib\index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Object.newLoader [as .js] (C:\my-project\node_modules\pirates\lib\index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.hookedLoader [as _load] (C:\my-project\node_modules\mockery\mockery.js:111:12)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at C:\my-project\node_modules\@wdio\cucumber-framework\build\index.js:204:13   

In my accountSummary_steps.js on line 6 is only this:

    import loggedInHeaderModule from "../pages/modules/loggedInHeaderModule"
    import accountSummaryPage from "../pages/accountSummaryPage"

import {Then, When} from 'cucumber';
    When(/^I click on My account details link$/, function () { // This is line 6
        loggedInHeaderModule.openAccountSummary();
    });  

This is my package.json dependencies:

"dependencies": {
    "@babel/cli": "^7.2.3",
    "@babel/plugin-proposal-export-default-from": "^7.5.2",
    "@babel/preset-env": "^7.4.2",
    "@babel/register": "^7.4.0",
    "@types/cucumber": "^7.0.0",
    "@wdio/cli": "^7.3.1",
    "@wdio/config": "^7.3.1",
    "@wdio/cucumber-framework": "^7.3.1",
    "@wdio/local-runner": "^7.3.1",
    "@wdio/selenium-standalone-service": "^7.3.1",
    "@wdio/spec-reporter": "^7.3.1",
    "@wdio/sync": "^7.3.1",
    "chai": "^4.3.4",
    "cucumber": "^6.0.5",
    "eslint-plugin-wdio": "^7.0.0",
    "file-system": "^2.2.2",
    "mjpeg-consumer": "^2.0.0",
    "node-fetch": "^2.6.1",
    "webdriverio": "^7.3.1",
    "yarn": "^1.22.10"
  },
  "devDependencies": {
    "@babel/core": "^7.4.0",
    "@wdio/allure-reporter": "^7.3.1",
    "@wdio/browserstack-service": "^7.3.1",
    "@wdio/junit-reporter": "^7.3.1",
    "babel-eslint": "^10.1.0",
    "babel-jest": "^26.6.3",
    "eslint": "^7.23.0",
    "eslint-plugin-import": "^2.22.1",
    "forever": "^3.0.4",
    "jest": "^26.6.3",
    "npm-run-all": "^4.1.5"
  }  

Anybody has any idea what went wrong there?
Thanks!


Solution

  • I managed to resolve it by removing "cucumber": "^6.0.5" dependency and using "@cucumber/cucumber": "^7.1.0" instead in package.json file.
    In my steps file I imported statements like this:

    import {Then, When} from '@cucumber/cucumber';    
    

    Instead of this:

    import {Then, When} from 'cucumber';  
    

    It seems it is the new way how webdriverIO v7 is integarted with cucumber. (Like described here in docs)