-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Automated Testing Guidelines for Gutenberg #939
Comments
Testing components can be viewed as somewhat useless in React as they are somewhat just supposed to work. Often times, I don't write tests for my view layer at all, but have found it is somewhat useful for tracking any regressions across upgrades of React, style sheets, etc. as a project evolves. Fully testing Here is my list of priorities in unit testing.
|
Thanks again for the work you're doing on unit tests. I mostly agree with all these priorities. I do feel that fully testing the components (especially the rendering) is not necessary at the moment because these components are often subject to change. That said, having more tests is better than having fewer tests, and if a test is problematic, it's easier to drop than having a missing test. |
Yeah, I figured we could just drop them if they start to be a pain. For now I will chop that list at number 3 then probably. Sound good? |
In general I am less worried about the specific conventions for tests than just that we have them in place. I agree the more the better. I think there are other types of tests that will be important to add. I'll try to list all the kinds I can think of here.
|
Part of what I like about the separation between the |
I'm not super convinced that we need to do this either, as we already encourage state access only through selector functions, which are tested. However I'm always happy to review PRs that add more tests. :) |
So should we export the presentational component, |
imo, we'd export a named export for the component, to be used in testing, then the default export is the export function MyComponent() {}
export default connect()( MyComponent ); We could make these two separate files, each with their own default export. In fact, this is a common pattern with container and presentational components. But I find it nigh discourages developers from connecting their components with sufficient granularity vs. creating overly broad container components. More pragmatic, if you would. |
You lost me 😓. Should we make the separate files, or is it not valuable enough to warrant the extra separation? I am having difficulty understanding what you want me to do. |
Component in a single file, with named presentational export for testing, default connected export for UI. |
Going to close this as it doesn't seem we have immediate actionable items. Feel free to reopen if you want to continue discussing. |
In conversation with jnylen, and youknowriad, there are definite grey areas around unit testing for Gutenberg. How should the assertions be styled? What conventions should be used? What should we test, and is markup testing useful? These are all concerns that should probably be ironed out into some sort of guideline so that testing can be done more streamlined and hopefully be consistent across contributors. Add your thoughts in the section below.
The text was updated successfully, but these errors were encountered: