webdriverio-boneyard / wdio-cucumber-framework

A WebdriverIO v4 plugin. Adapter for Cucumber testing framework.
MIT License
77 stars 61 forks source link

Using a Background throws error #135

Closed chrisahardie closed 6 years ago

chrisahardie commented 6 years ago

I have the following working test:

Feature:
  As a building manager, I can create a new access user

  Scenario: Empty first name will display error
      Given I open the site "/"
      And   I click on the element ".user-access"
      And   I click on the element ".create-user"
      When  I set "" to the inputfield "[name=firstname]"
      When  I press "Tab"
      Then  I wait on element "[data-error=firstname]" for 1000ms to be visible

I want to re-use the first three steps, so I create a background:

Feature:
  As a building manager, I can create a new access user

  Background:
      Given I open the site "/"
      And   I click on the element ".user-access"
      And   I click on the element ".create-user"

  Scenario: Empty first name will display error
      When  I set "" to the inputfield "[name=firstname]"
      When  I press "Tab"
      Then  I wait on element "[data-error=firstname]" for 1000ms to be visible

I now get this error in my output:

(node:13028) DeprecationWarning: cucumber: defineSupportCode is deprecated. Please require/import the individual methods instead.

ERROR: Cannot read property 'type' of undefined
chrome
Type    at CucumberReporter.getUniqueIdentifier (C:\Users\chardie\Documents\Repos\devcore\frontend\src\admin-app\node_modules\wdio-cucumber-framework\build\reporter.js:303:24)
    at CucumberReporter.handleBeforeStep (C:\Users\chardie\Documents\Repos\devcore\frontend\src\admin-app\node_modules\wdio-cucumber-framework\build\reporter.js:102:27)
    at emitMany (events.js:147:13)
    at CucumberEventListener.emit (events.js:224:7)
    at CucumberEventListener.onTestStepStarted (C:\Users\chardie\Documents\Repos\devcore\frontend\src\admin-app\node_modules\wdio-cucumber-framework\build\cucumberEventListener.js:159:18)
    at emitOne (events.js:121:20)
    at EventEmitter.emit (events.js:211:7)
    at TestCaseRunner.emit (C:\Users\chardie\Documents\Repos\devcore\frontend\src\admin-app\node_modules\cucumber\src\runtime\test_case_runner.js:51:27)
    at TestCaseRunner.<anonymous> (C:\Users\chardie\Documents\Repos\devcore\frontend\src\admin-app\node_modules\cucumber\src\runtime\test_case_runner.js:135:10)
    at Generator.next (<anonymous>)
    at Generator.tryCatcher (C:\Users\chardie\Documents\Repos\devcore\frontend\src\admin-app\node_modules\bluebird\js\release\util.js:16:23)
    at PromiseSpawn._promiseFulfilled (C:\Users\chardie\Documents\Repos\devcore\frontend\src\admin-app\node_modules\bluebird\js\release\generators.js:97:49)
    at TestCaseRunner.<anonymous> (C:\Users\chardie\Documents\Repos\devcore\frontend\src\admin-app\node_modules\bluebird\js\release\generators.js:201:15)
    at TestCaseRunner.aroundTestStep (C:\Users\chardie\Documents\Repos\devcore\frontend\src\admin-app\node_modules\cucumber\lib\runtime\test_case_runner.js:210:22)
    at C:\Users\chardie\Documents\Repos\devcore\frontend\src\admin-app\node_modules\cucumber\src\runtime\test_case_runner.js:202:18
    at Generator.next (<anonymous>)
------------------------------------------------------------------
[chrome #0-1] Session ID: 272dd00c995c6964ccbc2d6912f9ea03
[chrome #0-1] Spec: C:\Users\chardie\Documents\Repos\devcore\frontend\src\admin-app\integrationtests\src\features\userDetails.feature
[chrome #0-1] Running: chrome
[chrome #0-1]
[chrome #0-1]
[chrome #0-1]
[chrome #0-1]     Empty first name will display error
[chrome #0-1]       √ I set "" to the inputfield "[name=firstname]"
[chrome #0-1]       √ I press "Tab"
[chrome #0-1]       √ I wait on element "[data-error=firstname]" for 1000ms to be visible
[chrome #0-1]
[chrome #0-1]
[chrome #0-1] 3 passing (6s)
[chrome #0-1]

The test is still passing, I'm just getting that ERROR: Cannot read property 'type' of undefined message now. Also appears like subsequent scenarios are skipped.

Deps:

    "wdio-cucumber-framework": "2.1.0",
    "wdio-phantomjs-service": "0.2.2",
    "wdio-selenium-standalone-service": "0.0.9",
    "wdio-spec-reporter": "0.1.2",
    "webdriverio": "4.12.0"

Thanks for this great tool!

wswebcreation commented 6 years ago

Hmm, saw this also when I was making a PR for reporting. Will check the coming days if I can find the issue

veoh1989 commented 6 years ago

Any update on this issue? I'm having the same errors when attempting to use Background

Rob-Meijeren commented 6 years ago

I created a pull request that fixes this. could someone please check on that? https://github.com/webdriverio/wdio-cucumber-framework/pull/137

wswebcreation commented 6 years ago

@Rob-Meijeren , you kick ass man, tnx, see my feedback on the PR

Rob-Meijeren commented 6 years ago

@BorisOsipov @christian-bromann with version 2.2.2 this should be fixed. So this can be closed?

christian-bromann commented 6 years ago

Yes! Thanks!