-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Bind to Circus events via an optional event handler on any custom env. #8344
Bind to Circus events via an optional event handler on any custom env. #8344
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and clean! 😀
packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts
Outdated
Show resolved
Hide resolved
Maybe add a test that has the new function and just logs every event name or something? |
Another thing that came to my mind: export const makeEnvironmentDoCoolStuff = (BaseEnvironment: typeof JestEnvironment) =>
class CoolStuffEnvironment extends BaseEnvironment {
handleTestEvent(event, state) {
super.handleTestEvent(event, state);
doCoolStuff(event);
}
} It seems like this needs a composition mechanism. |
@jeysal I agree with you in principle but I tried that first and it's just more prone to errors. I think if we needed to do that, it's not mutually exclusive with also having this automatically available (easy mode) on the environment. |
@jeysal Also, to answer your core question of "how", I would probably:
Not the greatest but I think it may be the lesser of evils. |
Codecov Report
@@ Coverage Diff @@
## master #8344 +/- ##
==========================================
- Coverage 62.19% 62.17% -0.03%
==========================================
Files 266 266
Lines 10701 10702 +1
Branches 2603 2605 +2
==========================================
- Hits 6656 6654 -2
- Misses 3459 3462 +3
Partials 586 586
Continue to review full report at Codecov.
|
@SimenB test added, will merge on green |
@CompuIves this might be something you can use in code sandbox? |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
See #8307 for previous discussion.
This PR simplifies the implementation, exposing less API surface area and providing a clear method of implementation for the end-user.
Test plan
JEST_CIRCUS=1
.