allure-js
allure-js copied to clipboard
Uncaught TypeError: hook.error is not a function MochaAllureReporter
Describe the bug Getting an error when parallel mode is on while using Mocha
To Reproduce Steps to reproduce the behavior:
- Set parallel mode to true in mocha.rc config or use "--parallel" flag
- Run the tests
- Tests fail due to the following error: Uncaught TypeError: hook.error is not a function
Expected behavior
The tests should run successfully in parallel mode with Mocha allure reporter
Screenshots

Additional context the following version packages are used: "allure-mocha": "^2.0.0-beta.19", "mocha": "^9.2.1"
@darkallure if you patch MochaAllureReporter on line 70 with this block of code, do you still get the error? This resolved the issue for me, and I've opened a pull request to get the changes reviewed and merged:
node_modules/allure-mocha/dist/MochaAllureReporter.js line 70:
onHookEnd(hook) {
console.log('inside onHookEnd...');
if(typeof hook.error === 'function')
this.coreReporter.endHook(hook.error());
else
this.coreReporter.endHook();
}
@jamesmortensen thank you so much! It did fixed the issue but the other issue started to occur, do you know how to fix this?

@darkallure Not sure if that's related to this change or if it's another issue altogether which needs to be reported. It does seem like the v2.0.0 platform is still missing many of the 1.0 features, so my guess is new issue. If you check the source code, do you see any implementation for label?
@jamesmortensen Yes, I do see it:
The issue is not only with label but all the other properties as well: allure.suite, allure.description etc.
Can you try using the JavaScript Debug Terminal in VSCode to step through code in order to see what's missing? My guess is something is going on in the "model" that's being required.
@jamesmortensen it cannot even pass this line:
Do you have any other suggestions on what can be done to fix it or some kind of a workaround?
I'm not yet sure what runtime is supposed to be or where it comes from. It's supposed to be passed into the Allure constructor. I'm thinking it must be related to Mocha or Jest or Jasmine or whatever the runner is that's being used, but I'm not sure. Hopefully one of the maintainers of the project can jump in and give some insight.
Fixed in 2.0.0.beta-20 via #510. Remains fixed in 3.0.0-beta.3, which uses a different approach to the parallel mode.