-
Notifications
You must be signed in to change notification settings - Fork 160
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
Add parallel mode support #331
Conversation
@kolbasik can I try this locally? I'm assuming I just use the branch in my package.json instead of version right? |
Meantime until this PR is here. I am using the following patch in my project: https://gist.github.com/kolbasik/da92e9173bd262ac889cc7ed1d8e1b2e In order to use it you need to define it as custom reporter instead of original mocha --reporter ./mochawesome.js --parallel Plus, if you use |
@adamgruber Not sure if you have time but would be great to get this in. |
@kolbasik Thanks for the PR! I'd love for this reporter to be able to support parallel mode. I was doing some local testing with your branch and I'm seeing some inconsistencies with the reporter output between a normal test and a parallel test. These include:
To reproduce my local testing, update the npm scripts inside "test:fn": "mocha test-functional/ --config test-functional/.mocharc.json",
"test:par": "mocha --parallel test-functional/ --config test-functional/.mocharc.json", I think it's important that the results be the same whether run normally or in parallel. Or at least have good documentation on what differences to expect and why. |
fbe7dba
to
619f622
Compare
Hi @adamgruber , I have made changes according to your points.
I have extended Suite, Hook and Test to pass additional data from mocha worker to fix this case. $ mocha --reporter mochawesome --require mochawesome/register --parallel ./tests
Mocha does not provide information about skipped tests in parallel mode. Therefore, the skipped tests is always 0, and the total is less by the skipped value. I have mentioned about it in README as well.
Spawning worker processes is not free. So you should not use parallel option if tests are fast. Jest has the same behavior, for small amount of tests you need to use PS: I have added npm run test:par
npm run test:par -- --parallel |
Thanks, @adamgruber |
Hi @adamgruber, sorry for disturbance. You have released mochawesome 6.2.0 version and it should contain PS: I have created another PR to fix it #332 |
@kolbasik I know that Mocha's reporting in parallel mode is rather ... well ... suboptimal.
This is clearly a bug. Can you tell me, which additional properties you need, please? I'm in doubt about |
Hi @juergba, sorry for the delay, I was on vacation. Shortly, it is not about missing properties. It's more about Mochawsome feature. Mocha just has 3 states for the tests
And you could see that only those 3 states are handled by Mocha everywhere, listening to EVENT_TEST_PASS, EVENT_TEST_FAIL and EVENT_TEST_PENDING evetns
Mochawsome has the same states plus SKIPPED if the tests were not handled due to the exceptions in the hooks before. Lines 185 to 186 in b600095
In order to do that Mochawesome also tracks 2 more fields: total registered and total skipped. https://github.com/adamgruber/mochawesome/blob/master/src/mochawesome.js#L24-L27
So, here we could have misunderstanding between PENDING and SKIPPED. When devs use Lines 185 to 186 in b600095
Mochawesome is able to calculate the amount of SKIPPED tests only in sync mode since it has an access to the original list of Mocha's suites: https://github.com/adamgruber/mochawesome/blob/master/src/mochawesome.js#L207-L211 To reproduce above scenario and to get more details you could do the following:
beforeEach(() =>{
throw new Error("Skipped Test")
})
yarn mocha test-parallel --config test-parallel/.mocharc.json
yarn mocha test-parallel --config test-parallel/.mocharc.json --parallel
Therefore, Mocha does not send events about existing tests of workers if any errors occurred before the execution of that tests. Currently, Mochawesome resports shows the same information as default Mocha reports in the parallel mode. I hope that I have answered on your question. |
@kolbasik thank you for your reply. Yes, I'm not happy either with Mocha's hook pattern. A failing hook drops its corresponding tests, they just disappear without any reporting. Btw besides the existing test states (PASS, FAIL, PENDING (skipped)) and the skipped-by-hook-failure: maybe DROPPED (you name it SKIPPED), there is one more state missing:
If you extend the |
Hi @jurgen, thank you for your suggestion regarding the |
@kolbasik thanks. |
Can you remove me from this project, I'm not a developer for this project.
Thanks
Jurgen
…On Thu, Oct 7, 2021 at 8:01 AM Juerg B. ***@***.***> wrote:
@kolbasik <https://github.com/kolbasik> thanks.
What about the speed loss by the serialization of the complete root suite,
is there any advantage left between serial <=> parallel mode?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#331 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAACLZYII5L7HVKSVAT3D3DUFUZT5ANCNFSM4TBESW2Q>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
@juergba , no matter how much time is the overhead of running tests in parallel.
|
- MOCKM_REGISTRY 环境变量用于保证稳定的自动安装依赖 - --require 用于处理并行测试时不能正确显示 html - adamgruber/mochawesome#331
- MOCKM_REGISTRY 环境变量用于保证稳定的自动安装依赖 - --require 用于处理并行测试时不能正确显示 html - adamgruber/mochawesome#331
Resolve #321
Purposes:
PS: mocha uses a custom test serializer so I have extended their serializer to consume the
context
as well