Skip to content

docs: Add 'What this library can't test' section #575

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

Merged
merged 5 commits into from
Aug 27, 2020

Conversation

kalpeshsingh
Copy link
Contributor

This PR is regarding #574 issue.

This will help newbies developers to understand the purpose of the library and what is not expected out of it.
This will help developers to understand guiding principles better.

@nickserv
Copy link
Member

Technically these things can be tested, but only indirectly (unlike Enzyme, testing library doesn't provide APIs for accessing them directly). Maybe we could word it so it's more about avoiding testing internals by not supporting APIs like that, similar to what's in the docs but a bit simpler and easier to learn at a glance. I still think these are three good topics though.

@kalpeshsingh
Copy link
Contributor Author

kalpeshsingh commented Aug 24, 2020

Sounds fair and reasonable, @nickmccurdy.
Here is re-worded version.

What you should avoid with Testing Library

Testing Library encourage you to avoid testing internals of the component (though you can test them). The Guiding Principles of this library emphasize on tests that closely resemble how your web pages are interacted by the users.

You may want to avoid following internals for testing -

  1. Internal state of the component
  2. Internal methods
  3. Lifecycle methods of the component
  4. Child component

If this adds value to developers then I can update PR.

@kentcdodds
Copy link
Member

I'm ok with including something like this, but not on this page. DOM Testing Library doesn't really have anything to do with components directly. That's a framework-specific thing.

@alexkrolick
Copy link
Collaborator

Feel free to reuse this content from an old article I wrote: https://medium.com/@alexkrolick/what-makes-a-good-test-dff3df6058a2#0843
Screen Shot 2020-08-24 at 10 32 57 AM

@kalpeshsingh
Copy link
Contributor Author

@kentcdodds - This will be right below What this library is not section on Introduction page.
Attaching marked screenshot.

testing library intro page

@kentcdodds
Copy link
Member

Ah, yeah, that makes sense 👍

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a few minor modifications. Thanks!

@kentcdodds kentcdodds merged commit 330132d into testing-library:master Aug 27, 2020
@kentcdodds
Copy link
Member

@all-contributors please add @kalpeshsingh for docs

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @kalpeshsingh! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants