Bind to Circus events via an optional event handler on any custom env.#8344
Conversation
|
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.