allure-js icon indicating copy to clipboard operation
allure-js copied to clipboard

allure-cucumber-js - Cannot read property 'sourceLocation' of undefined when running with --parallel

Open Bakanych opened this issue 5 years ago • 6 comments

I'm submitting a ...

  • [x] bug report
  • [ ] feature request
  • [ ] support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

Allure-cucumberjs is used as a reporter for cucumber-js test framework. When I run tests using --parallel flag, test runner throws error:

TypeError: Cannot read property 'sourceLocation' of undefined
    at AllureReporter.onTestStepStarted (.../node_modules/allure-cucumberjs/src/CucumberJSAllureReporter.ts:192:18)
    at EventEmitter.emit (events.js:189:13)
    at Master.parseSlaveMessage (.../node_modules/cucumber/lib/runtime/parallel/master.js:55:31)
    at ChildProcess.slave.process.on.message (.../node_modules/cucumber/lib/runtime/parallel/master.js:83:12)
    at ChildProcess.emit (events.js:189:13)
    at emit (internal/child_process.js:820:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Please tell us about your environment:

Allure version
Test framework "cucumber": "^6.0.5"
Allure adaptor allure-cucumberjs": "^2.0.0-beta.6"

Bakanych avatar Jan 29 '20 08:01 Bakanych

The same error I have

yevgen-getalo avatar Apr 15 '20 08:04 yevgen-getalo

Same issue

arsena avatar Jun 25 '20 13:06 arsena

I'm guessing this hasn't been solved yet?

mikejoo avatar Jul 10 '20 05:07 mikejoo

Can you please recommend if using --parallel flag is fixable? I'd be interested in diving into it. Love Allure/Cucumber reports but if we can't speed up the tests, we might need to look for an alternative to this library.

arsena avatar Dec 08 '20 01:12 arsena

I've been debugging this issue; I don't have any solutions right now but I will share what I have found in hopes it can shed some more light on the issue.

When tests are run in parallel, this declaration when called here causes test runs to fail. Examining the objects, there are discrepancies in the data but I have not found the source. During serial (non-parallel) tests, the object declaration's output is good

line:270 from the source code

const location = this.stepsMap.get(SourceLocation.toKey(data.testCase)) || [])[data.index]
[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 7 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 10 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 8 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 14 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 7 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 10 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 8 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 14 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 7 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 10 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 8 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 14 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 7 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 10 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 8 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 14 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 7 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 10 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 8 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 14 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 7 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 10 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 8 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 14 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 7 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 10 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 8 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 14 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/login.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 6 } },
  { sourceLocation: { uri: 'features/login.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 9 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/login.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 6 } },
  { sourceLocation: { uri: 'features/login.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 9 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/login.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 6 } },
  { sourceLocation: { uri: 'features/login.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 9 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/login.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 6 } },
  { sourceLocation: { uri: 'features/login.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 9 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/login.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 6 } },
  { sourceLocation: { uri: 'features/login.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 9 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/login.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 6 } },
  { sourceLocation: { uri: 'features/login.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 9 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.

2 scenarios (2 passed)
5 steps (5 passed)
0m04.481s

Compare to the output when --parallel is called:

[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 7 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 10 } },
  { sourceLocation: { uri: 'features/homepage.feature', line: 8 },
    actionLocation: { uri: 'features/step_definitions/homepage.js', line: 14 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
[ { actionLocation: { uri: 'features/support/hooks.js', line: 7 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 11 } },
  { sourceLocation: { uri: 'features/login.feature', line: 6 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 6 } },
  { sourceLocation: { uri: 'features/login.feature', line: 7 },
    actionLocation: { uri: 'features/step_definitions/landing.js', line: 9 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 21 } },
  { actionLocation: { uri: 'features/support/hooks.js', line: 17 } } ]
.undefined
redacted/node_modules/allure-cucumberjs/dist/src/CucumberJSAllureReporter.js:153
        if (location.sourceLocation !== undefined && feature.stepMap !== undefined) {
                     ^

TypeError: Cannot read property 'sourceLocation' of undefined
    at CucumberJSAllureFormatter.onTestStepStarted (redacted/node_modules/allure-cucumberjs/dist/src/CucumberJSAllureReporter.js:153:22)
    at EventEmitter.emit (events.js:198:13)
    at EventEmitter.emit (domain.js:448:20)
    at Master.parseSlaveMessage (redacted/node_modules/cucumber/lib/runtime/parallel/master.js:55:31)
    at ChildProcess.slave.process.on.message (redacted/node_modules/cucumber/lib/runtime/parallel/master.js:83:12)
    at ChildProcess.emit (events.js:198:13)
    at ChildProcess.EventEmitter.emit (domain.js:448:20)
    at emit (internal/child_process.js:832:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

By the time the script gets to the conditional on line: 282 the location object contains "bad" data and no longer meets the requirements for the script(s) to continue.

if (location.sourceLocation !== undefined && feature.stepMap !== undefined)

I will continue to dissect the issue, however, please help. :)

emarty-maze avatar Mar 21 '21 04:03 emarty-maze

https://github.com/korobochka/cucumberjs-allure2-reporter/issues/6

fescobar avatar Jul 12 '21 12:07 fescobar

Should be fixed in the last release. Feel free to reopen the issue, if it still doesn't work for you.

epszaw avatar Nov 23 '22 14:11 epszaw