-
-
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
Feature: broader uses for watch plugins #6473
Feature: broader uses for watch plugins #6473
Conversation
Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours has expired. Before we can review or merge your code, we need you to email cla@fb.com with your details so we can update your status. |
Codecov Report
@@ Coverage Diff @@
## master #6473 +/- ##
==========================================
- Coverage 63.61% 63.58% -0.04%
==========================================
Files 235 235
Lines 8971 8991 +20
Branches 3 4 +1
==========================================
+ Hits 5707 5717 +10
- Misses 3263 3273 +10
Partials 1 1
Continue to review full report at Codecov.
|
@rogeliog this is for your reviewing pleasure 😉 |
|
||
#### Authorized configuration keys | ||
|
||
For stability and safety reasons, only part of the global configuration keys can be updated with `updateConfigAndRun`. The current white list is as follows: |
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.
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.
Hey @SimenB!
--changedSince
and--lastCommit
do not have any direct equivalent in the global configuration object. They're used bygetChangedFilesForRoots
injest-changed-files
, and are also ignored when--onlyChanged
(which is the default watch mode), so they don't seem to make sense in that mode. At any rate, the watch architecture would not let us change that on the fly right now, this is a bootstrap-time computation.--onlyChanged
is already togglable in watch mode: these are thea
key (all tests, same as--watchAll
) vs.o
key (only changed tests, same as--onlyChanged
).--logHeapUsage
does have a matching boolean in the global config, so I'm open to adding it, what do others think?
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.
in the same way toggling onlyChanged
is useful, I think changedSince
would be useful. It would then overwrite onlyChanged
.
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.
@SimenB I agree it would be nice, but Jest's current architecture doesn't let us do it. It computes the watched list at boot time, then keeps it in a closure where specific global config options may amend it (such as the watch mode). There's no stuff in there right now for changedSince
or lastCommit
, and I feel the change would be significant.
This specific PR is bound by what's in the global config. Should this feature set become config-based, I'll be glad to expand the white list, but it's a different feature scope IMHO.
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.
@rogeliog sounds like we need another of your magical refactor runs 😀
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.
Yeah we would need to change a couple of things in order to make that happen 🙃
{virtual: true}, | ||
); | ||
|
||
// updateGlobalConfig.mockReset(); |
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.
?
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.
Woops, forgot to strip this 😒
@@ -86,6 +86,11 @@ jest.doMock( | |||
{virtual: true}, | |||
); | |||
|
|||
const regularUpdateGlobalConfig = require('../lib/update_global_config') |
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.
You can import
it to avoid the .default
call
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.
Yes, but as I'm mocking it right the next line, it seemed more interesting to keep it close by?
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.
jest.doMock
should be called prior to require call
@tdd did you see the CLA comment? |
@SimenB I did see the CLA comment and e-mailed to update and renew my CLA status. The online form fails in obscure ways for updates (always has, nobody's fixing it). |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
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.
Thanks for the PR! I'm excited about this!
|
||
#### Authorized configuration keys | ||
|
||
For stability and safety reasons, only part of the global configuration keys can be updated with `updateConfigAndRun`. The current white list is as follows: |
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.
Yeah we would need to change a couple of things in order to make that happen 🙃
); | ||
|
||
// updateGlobalConfig.mockReset(); | ||
const whiteListedOptions = [ |
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 we could use it.each([objectWithWhitelistedOptionsAndOtherOptions])('')
https://facebook.github.io/jest/docs/en/api.html#testeachtable-name-fn
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.
Right! Good point… Let me try…
packages/jest-cli/src/watch.js
Outdated
} = {}) => { | ||
const previousUpdateSnapshot = globalConfig.updateSnapshot; | ||
// It is unfortunate that Flow isn't smart enough yet to let us | ||
// implement a generic assign loop over a list of white-listed | ||
// option names here :-( | ||
globalConfig = updateGlobalConfig(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.
Now that there are a lot of options, maybe we could move a lot of this !== undefined
logic into the updateGlobalConfig
function, so that it is the only place that knows how to handle all of that logic
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.
Yeah, that's an option. I really disliked the un-DRYness of this part of the code, but making it dynamically iterate over a list of props confused the heck out of Flow 😒 .
I'll try and move that logic inside updateGlobalConfig
and see how it goes.
Hey @rogeliog! Here's my update. It addresses the various suggestions you had, and it looks like it's going to greenlight through. Let me know what the next steps would be! |
Hey @rogeliog just following up on this. Have you had time to peruse the latest changes? I'd love to know how and when we can move ahead with this 😉 |
ca07148
to
a5f5c4b
Compare
Just pushed a force update to fix upstream merge conflicts over |
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.
Awesome! Thanks a lot!
@tdd mind resolving conflicts? :) |
@thymikee dang, there were none when this was originally approved. Also, all checks passed. Checking it now. |
Grmbl, this thing stayed too long in limbo, approved but unmerged, as other PRs for watch plugins came in that broke this one. Will need to investigate. (Also, not cool, team 😐 ) |
I'm pretty sure @rogeliog can help you with figuring out what's wrong now :). |
Hey @thymikee I sure would appreciate @rogeliog's help on this, the issue is the same across the board, when |
Yes, I'm more than happy to help. I'll take a look |
Hey all! FWIW the initial release of the toggle-config plugin is out, now that 23.4.1 includes this. Will move it to jest-community soon. Check it out: https://github.com/deliciousinsights/jest-watch-toggle-config#readme |
- 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.
Done, and added you as admin |
Awesome, thank you! |
- 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 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
As discussed in #6467, watch plugins could be much more useful if they could change a wider range of global config options. This implements a white-listed wider set, tests and docs it.
Two immediate use cases are toggler plugins for tests verbosity and coverage collection. They're already ready and tested on my local machine, but I have no idea how to get them inside the
jest-community
org, and I'll need the relevant minimum Jest version for a pertinentpeerDependency
.Test plan
All tests pass on my machine. Extra tests are located in
packages/jest-cli/__tests__/watch.test.js
, and focus on confirming white-listing of allowed global config options is effective.The docs in
/docs
were also updated (but they don't seem to be used bywebsite/
'syarn start
oryarn build
, so I only checked their rendering in VS Code's Markdown preview).This is not semver-major, as there are no breaking changes IMHO, this is more of an extra feature, so looks semver-minor to me.
Hope you like it!
Closes #6467