-
-
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
Allow plugins to override other plugins #5878
Conversation
78afdd1
to
1b66369
Compare
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.
This is amazing, shaping up! :D
return -1; | ||
} | ||
|
||
const usageInfoA = a.getUsageInfo && a.getUsageInfo(globalConfig); |
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.
Should the base class every watch plugin extends have a getUsageInfo
function which returns null
or empty string so you don't have to check for its existence?
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.
I think this will make the implementation easier, but I'm worried about making the API for the consumers a bit harder. Given that there will be plugins that do not implement it
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.
I sometimes wonder if we should just move everything to be a jest hook, and make the whole API just around jest hooks
class MyPlugin {
apply(jestHooks) {
jestHooks.run(/* ... */);
jestHooks.getUsageInfo(/* ... */);
jestHooks.testRunComplete(/* ... */);
jestHooks.fsChange(/* ... */);
jestHooks.onData(/* ... */);
jestHooks.shouldRunTestSuite(/* ... */);
}
}
instead of
class MyPlugin {
apply(jestHooks) {
jestHooks.testRunComplete(/* ... */);
jestHooks.fsChange(/* ... */);
jestHooks.shouldRunTestSuite(/* ... */);
}
onData(/* ... */) {
/* ... */
}
run(/* ... */) {
/* ... */
}
getUsageInfo(/* ... */) {
/* ... */
}
}
Seems like the plugin architecture is working already, which means that changing to an API like the one above should not be that hard.
This means that the apply
method is the only method that exists in the class and everything else is a jestHook. Seems that if we would like to make this changes it is better to do them now than later.
thoughts? Which API seems cleaner? Which API would be easier to document?
@rickhanlonii @orta @cpojer @SimenB
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.
I'm worried about the first API being too open. There are other open source tools out there that allow people to do anything they want in a plugin and it generally causes the entire system to slow down considerably. I think we should stick with a more limited API that guides user to build plugins in the way we expect them to be built. Of course, it's still possible to completely break out of that system and do harmful slow things but it is less likely to happen.
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.
+1 to @cpojer and I like that the current Watch Plugin API is similar in structure to the runner and reporter - implement a class with a specific structure
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.
+1 - slow and deliberate improvements as we need them, I think this looks great
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.
Perfect! 😄
OMG it's happening. |
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. |
This PR allows third party plugins to override the "key" that an internal plugin is using.
Contributes to #5478
Summary
Test plan