allure-framework / allure-js

Allure integrations for JavaScript test frameworks
https://allurereport.org/
Apache License 2.0
225 stars 122 forks source link

Mocha parallel mode and Allure API #619

Closed epszaw closed 5 months ago

epszaw commented 1 year ago

Describe the bug We have a problem related to mocha parallel mode for a long time, there is some related issues in the repository: #485, #486.

To Reproduce Steps to reproduce the behavior:

  1. Use allure mocha reporter in parallel mode
  2. Try to call any allure API method such as label
  3. You'll see an error in console

Expected behavior We should be able to use Allure API with mocha in parallel mode.

Additional context At this moment, the problem can't be solved because mocha parallel mode implementation. The running uses workerpool module, what doesn't work with plain node IPC messages. Additionally, mocha doesn't provide any way to send messages from tests to the reporter, what works in the main thread, so we can't do anything at this moment to make both parts work correctly.

As temporal solution, I suggest to use single thread mode, if you need Allure API.

All the updates about the problem I'll post here, in the issue.

islam-tenovos commented 1 year ago

@baev so it is the solution that error will be displayed only. I need help how to implement allure mocha for mocha parallel tests.

baev commented 1 year ago

Mocha does not support the feature. From the issue description:

At this moment, the problem can't be solved because mocha parallel mode implementation. The running uses workerpool module, what doesn't work with plain node IPC messages. Additionally, mocha doesn't provide any way to send messages from tests to the reporter, what works in the main thread, so we can't do anything at this moment to make both parts work correctly.

We tried to connect with mocha developers to address the issue, actively pushing them for more than six months. So far, we have yet to be successful. They don't accept the PR, and they don't respond to issues.

It is not Allure specific issue. There is no other reporter that solves the same problem. I suggest using Mocha in single-threaded mode. Or rewrite the tests using playwright

baev commented 1 year ago

If you have any idea how we can solve the problem -- feel free to mention it here, our team is always happy to help.

islam-tenovos commented 1 year ago

@baev can you or anyone in the team take a look on the project i have attached and see if there is any possibility to achieve the required. There are many tests we already written and working single thread with mocha and allure reporter. Now i want to run them parallel. mocha-project.zip

baev commented 1 year ago

if there is any possibility to achieve the required

I don't think this is possible without major Mocha refactoring and collaboration from the Mocha team