-
-
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
Improve DX for watch plugin key conflicts #6693
Comments
Working on a PR for this, I realized some of the tests for #6473 actually passed by mistake, as the syntax for the |
I went with a separate PR (#6696) for the test-fixing part, seemed like the cleaner thing to do. Working on a PR for the tentative spec in this issue now. |
- Some built-in keys remain overridable (specificically `t` and `p`). - Any key registered by a third-party watch plugin cannot be overridden by one listed later in the plugins list config. Fixes jestjs#6693. Refs jestjs#6473.
- Some built-in keys remain overridable (specificically `t` and `p`). - Any key registered by a third-party watch plugin cannot be overridden by one listed later in the plugins list config. Fixes jestjs#6693. Refs jestjs#6473.
- Some built-in keys remain overridable (specificically `t` and `p`). - Any key registered by a third-party watch plugin cannot be overridden by one listed later in the plugins list config. Fixes jestjs#6693. Refs jestjs#6473.
- Some built-in keys remain overridable (specificically `t` and `p`). - Any key registered by a third-party watch plugin cannot be overridden by one listed later in the plugins list config. Fixes jestjs#6693. Refs jestjs#6473.
- Some built-in keys remain overridable (specificically `t` and `p`). - Any key registered by a third-party watch plugin cannot be overridden by one listed later in the plugins list config. Fixes jestjs#6693. Refs jestjs#6473.
- Some built-in keys remain overridable (specificically `t` and `p`). - Any key registered by a third-party watch plugin cannot be overridden by one listed later in the plugins list config. Fixes jestjs#6693. Refs jestjs#6473.
- Some built-in keys remain overridable (specificically `t` and `p`). - Any key registered by a third-party watch plugin cannot be overridden by one listed later in the plugins list config. Fixes jestjs#6693. Refs jestjs#6473.
- Some built-in keys remain overridable (specificically `t` and `p`). - Any key registered by a third-party watch plugin cannot be overridden by one listed later in the plugins list config. Fixes jestjs#6693. Refs jestjs#6473.
## Summary Watch plugins now are checked for key conflicts… - Some built-in keys remain overridable (specificically `t` and `p`). - Any key registered by a third-party watch plugin cannot be overridden by one listed later in the plugins list config. Fixes #6693. Refs #6473. ## Test plan Additional tests are provided that check every conflict / overwritable scenario discussed. ## Request for feedback / “spec” evolution The “spec” is an ongoing discussion in #6693 — in particular, the overwritability of some built-in keys, such as `a`, `f` and `o`, may be subject to discussion. This PR tracks the decisions in there and may evolve a bit still. Ping @SimenB @thymikee @rogeliog for review and discussion.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🚀 Feature Proposal
Jest should ensure automagically that:
q
for quitting)Motivation
(For context, not this was discussed at some length already in #6473, around the end of the thread.)
Watch plugins have as an explicit design goal the ability to override built-in plugin key bindings. This lets plugins such as jest-watch-typeahead replace the built-in behavior bound to keys
p
andt
with one that features typeahead, for instance.However, some built-in features provided as plugins should quite likely not be overridden. For instance, the (rather essential) ability to quit the Jest watcher, using the
q
key, is provided by a built-in plugin, as is snapshot management, both ballpark withu
and interactive withi
.Furthermore, third-party plugins should quite likely not be allowed to silently overwrite each other's key bindings, a situation that is quite difficult to debug when multiple plugins are used. Jest should check for this, report in a useful manner and exit with an appropriate code (e.g.
EX_USAGE
, that is 64).Example
Here are a list of intended behaviors:
p
ort
should remain valid.q
(quit) andw
(watch usage) should error out, something like this:a
(all),c
(clear patterns),o
(only changed) andf
(failures first) should be overwritable. They currently have special handling here and there inwatch.js
, as doq
and Enter by the way. I'm also not sure what?
is supposed to do: it is handled in the code butbreak
s immediately, resulting in a no-op.watchPlugins
configuration entry) should error out, listing the conflicting plugins and the key, something along these lines:Pitch
This belongs in Jest because the only code location that “sees all the keys” is Jest's
watch.js
module. Even if we left it up to individual plugin authors to deal with this (which is terrible DX IMHO), it would still mean Jest passes a keymap of sorts to them at construction time, so Jest's codebase is impacted.PR
I'm starting a PR to deal with this, but would very much welcome spec refinement. In particular, I'd invite @thymikee, @rogeliog and @SimenB to continue the discussion here that we had started in #6473.
The text was updated successfully, but these errors were encountered: