-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
"hook" event is triggered after "test" event #4266
Comments
As it's hard to reuse current allure-mocha implementation within other frameworks or libraries, there were made the following modifications: - updated package dependencies to the latest versions; - updated typescript dependency in a root module, as re-exporting issue is already fixed; - replaced deprecated `mocha-typescript` with `@testdeck/mocha`; - added before/after hooks handlers (note that before hook won't work as expected until [mocha issue](mochajs/mocha#4266) is fixed or we revise the current contexts' switching approach); - added `AllureContainer` to the `allure-js-commons` package for easier decorators' implementation; - covered `epic` feature; - updated all the tests to support `@testdeck/mocha`.
As it's hard to reuse current allure-mocha implementation within other frameworks or libraries, there were made the following modifications: - updated package dependencies to the latest versions; - replaced deprecated `mocha-typescript` with `@testdeck/mocha`; - added before/after hooks handlers (note that before hook won't work as expected until [mocha issue](mochajs/mocha#4266) is fixed or we revise the current contexts' switching approach); - covered `epic` feature; - updated all the tests to support `@testdeck/mocha`.
As it's hard to reuse current allure-mocha implementation within other frameworks or libraries, there were made the following modifications: - updated package dependencies to the latest versions; - replaced deprecated `mocha-typescript` with `@testdeck/mocha`; - added before/after hooks handlers (note that before hook won't work as expected until [mocha issue](mochajs/mocha#4266) is fixed or we revise the current contexts' switching approach); - covered `epic` feature; - updated all the tests to support `@testdeck/mocha`.
Hi @sskorol .
Im confused by the issue. The runner will run the before "hooks", then the "test", then the after "hooks". The hooks all have a "hook start" event, so why would "afterEach" not have one? I see you are listening for the |
Hi @craigtaub , Apologies if I introduced such confusion. Probably the following screenshot would explain the issue better: What I've been talking about is "before each" hook's execution order. I expect to see a P.S. Sorry, I didn't get what you meant by "listen to a more specific (afterEach) hook event". I don't need
For now, |
Yes I see what you mean. The runner fires It appears only the "list" reporter listens for @mochajs/core any thoughts on this? |
This behaviour is not a bug, it was designed like this back in ancient times. We have integration tests for checking the event order, and there already are similar issues. This is not a trivial topic, there should be good reasons for a change. It affects at least:
|
Thanks.
@sskorol unfortunately this is an outstanding nontrivial bug which has not been resolved yet. Perhaps there is an alternative approach you can take? |
@craigtaub @juergba the main problem I see here is that such a design flaw on the core level may force API users to create workarounds for all potential child reporters. This issue won't be annoying unless you need to collect some internal metadata from within the hook's body and physically save or send it somewhere in real-time. In this case, the wrong execution order might affect the child reporter's architecture or cause misinterpreting results by the receiver side. Of course, workarounds are always possible. But I would be greatly appreciated if such issues are considered for fixing on the core level. |
Per #5027, we're not looking to make any major changes to Mocha at this point. |
Prerequisites
faq
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.Description
When we create a custom reporter with common events' handlers as described here,
hook
is always triggered aftertest
event, that seems incorrect.Steps to Reproduce
See a min repo to reproduce the issue.
Expected behavior:
hook
event is triggered beforetest
event.Actual behavior:
hook
event is triggered aftertest
event.Reproduces how often: 100%
Versions
mocha --version
andnode node_modules/.bin/mocha --version
: 7.1.2node --version
: v13.13.0The text was updated successfully, but these errors were encountered: