-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Define end-to-end test experimental features utility as lifecycle helper #22712
Conversation
Size Change: 0 B Total Size: 1.12 MB ℹ️ View Unchanged
|
@@ -11,7 +11,7 @@ import { | |||
/** | |||
* Internal dependencies | |||
*/ | |||
import { enableExperimentalFeatures } from '../../experimental-features'; | |||
import { useExperimentalFeatures } from '../../experimental-features'; |
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.
It reads like React hook because of the use
prefix 🙃
Edit: Now I read description, it's intended 👍
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, intentional in that the purpose is largely the same in utilities to manage lifecycle. But I grant they are quite different as far as the underlying implementation, and there is some potential for confusion. It feels like the chance of actual conflict is fairly low. I'm open to different naming. In the original Slack conversation, I mentioned withFooEnabled
as an example, though there's a similar issue there with how we tend to use with
prefixes for higher-order functions. I also don't think that React should hold exclusive rights to this prefix, since it's quite generic.
🤷
It's an internal utility, so it can be changed in the future. I do like the idea of propagating this sort of pattern for the general requirement of test lifecycle utilities, so at some point a pattern should be established if it becomes more commonplace.
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.
It’s totally fine. I like this parallel. I just wanted to emphasize how this concept changed the perception when reading code outside of the React context (it wasn’t intentional to use double meaning here but now I find it funny).
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 do like the idea of propagating this sort of pattern for the general requirement of test lifecycle utilities
Related: #22804
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, I double-checked those previously used helpers aren't part of public API – they aren't.
Awesome. Thanks for this! |
Related Slack conversation (link requires registration): https://wordpress.slack.com/archives/C02QB2JS7/p1590677131416000
This pull request seeks to resolve intermittent failures of end-to-end tests, where the block directory end-to-end test suite does not currently tear down to reset experimental features to the initial state, causing subsequent tests run in the same container to unexpectedly run with the block directory experiment enabled. This causes builds to fail due to a related issue with ARIA attributes not being applied:
Example: https://travis-ci.com/github/WordPress/gutenberg/jobs/340966385
Implementation Notes:
The implementation here addresses this by encapsulating the entire lifecycle requirements of enabling experimental features into a single utility, thus avoiding the potential to overlook the need to provide a
afterEach
tear-down.The idea here is to promote a pattern that in cases where something should be "activated" before and "deactivated" after a test is run, we should prefer to create a single utility which manages the full lifecycle of the behavior in a test. In this way, it behaves a lot like a React Hook.
Before:
After:
Testing Instructions:
Ensure end-to-end tests pass: