Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: hook.error is not a function MochaAllureReporter #482

Closed
darkallure opened this issue Aug 19, 2022 · 8 comments
Closed
Labels
theme:mocha Mocha related issue

Comments

@darkallure
Copy link

darkallure commented Aug 19, 2022

Describe the bug
Getting an error when parallel mode is on while using Mocha

To Reproduce
Steps to reproduce the behavior:

  1. Set parallel mode to true in mocha.rc config or use "--parallel" flag
  2. Run the tests
  3. 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
image
image

Additional context
the following version packages are used:
"allure-mocha": "^2.0.0-beta.19",
"mocha": "^9.2.1"

@jamesmortensen
Copy link

@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();
    }

@darkallure
Copy link
Author

darkallure commented Aug 20, 2022

@jamesmortensen thank you so much! It did fixed the issue but the other issue started to occur, do you know how to fix this?
image
image

@jamesmortensen
Copy link

@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?

@darkallure
Copy link
Author

darkallure commented Aug 22, 2022

@jamesmortensen Yes, I do see it:
image
The issue is not only with label but all the other properties as well: allure.suite, allure.description etc.

@jamesmortensen
Copy link

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.

@darkallure
Copy link
Author

@jamesmortensen it cannot even pass this line:
image
Do you have any other suggestions on what can be done to fix it or some kind of a workaround?

@jamesmortensen
Copy link

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.

@vovsemenv vovsemenv added the theme:mocha Mocha related issue label Feb 9, 2023
@delatrie
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:mocha Mocha related issue
Projects
None yet
4 participants