webdriverio-boneyard / wdio-cucumber-framework

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

Reporters fails on running cucumber before\after hooks #105

Closed BorisOsipov closed 6 years ago

BorisOsipov commented 6 years ago

After update to wdio-cucumber 2.0.0 version.

If there are cucumber tests with hooks reporters fails with an error.

...ERROR: Cannot read property 'name' of undefined
phantomjs
Type    at CucumberReporter.getUniqueIdentifier (C:\Users\bo\WebstormProjects\untitled5\node_modules\wdio-cucumber-framework\build\reporter.js:297:30)
    at CucumberReporter.handleBeforeStep (C:\Users\bo\WebstormProjects\untitled5\node_modules\wdio-cucumber-framework\build\reporter.js:96:27)
    at emitMany (events.js:146:13)
    at CucumberEventListener.emit (events.js:223:7)
    at CucumberEventListener.onTestStepStarted (C:\Users\bo\WebstormProjects\untitled5\node_modules\wdio-cucumber-framework\build\cucumberEventListener.js:159:18)
    at emitOne (events.js:120:20)
    at EventEmitter.emit (events.js:210:7)
    at TestCaseRunner.emit (C:\Users\bo\WebstormProjects\untitled5\node_modules\cucumber\src\runtime\test_case_runner.js:51:27)
    at TestCaseRunner.<anonymous> (C:\Users\bo\WebstormProjects\untitled5\node_modules\cucumber\src\runtime\test_case_runner.js:135:10)
    at Generator.next (<anonymous>)
    at Generator.tryCatcher (C:\Users\bo\WebstormProjects\untitled5\node_modules\bluebird\js\release\util.js:16:23)
    at PromiseSpawn._promiseFulfilled (C:\Users\bo\WebstormProjects\untitled5\node_modules\bluebird\js\release\generators.js:97:49)
    at TestCaseRunner.<anonymous> (C:\Users\bo\WebstormProjects\untitled5\node_modules\bluebird\js\release\generators.js:201:15)
    at TestCaseRunner.aroundTestStep (C:\Users\bo\WebstormProjects\untitled5\node_modules\cucumber\lib\runtime\test_case_runner.js:210:22)
    at C:\Users\bo\WebstormProjects\untitled5\node_modules\cucumber\src\runtime\test_case_runner.js:202:18
    at Generator.next (<anonymous>)

Error apprears because cucumber emits testStepStartedEvent for before\after hooks as well as for steps. In such a case reporting works wrong. Sample repo for reproducing issue https://github.com/BorisOsipov/wdio-cucumber4-issue

/cc @mhoyer

BorisOsipov commented 6 years ago

Just FIY.

I went deep into this issue and realized that is not so easy to fix cucumber hooks bugs. I'd like to recommend people how meet this issue use wdio before\after hooks instead of cucumbers hooks.

mhoyer commented 6 years ago

@BorisOsipov, I'm going to check it too the next days.