Skip to content
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

Thoughts on including react-testing-library in the default template? #6358

Closed
kentcdodds opened this issue Feb 7, 2019 · 9 comments · Fixed by #7881
Closed

Thoughts on including react-testing-library in the default template? #6358

kentcdodds opened this issue Feb 7, 2019 · 9 comments · Fixed by #7881
Assignees
Milestone

Comments

@kentcdodds
Copy link
Contributor

Now that React is officially recommending people use react-testing-library, I wonder whether people would be in favor of including it by default. I made a video about what you need to do to add react-testing-library to create-react-app:

https://www.youtube.com/watch?v=Yx-p3irizCQ&list=PLV5CVI1eNcJgCrPH_e6d57KRUTiDZgs0u&t=60s

This commit is me adding the library and setup: kentcdodds/create-react-app-react-testing-library-example@ad467ae

Note: In that commit and video I demo how to include jest-dom which I think would be good to include as well, but I have no problem if ya'll would prefer not to include that.

I'd love to see a 👍 if you're in favor and a 👎 if you're not. I promise to not tweet about this issue myself to avoid bringing unfair attention in my favor (though others can feel free to if they want 😉).

@ianschmitz
Copy link
Contributor

Hey Kent. I think this would fit in nicely with #6270 as a template. What do you think?

@kentcdodds
Copy link
Contributor Author

I'm not sure what you mean. Are you suggesting this should be included in the -minimal template rather than the default? That seems counter-intuitive. I would assume that "minimal" would be as little as possible to make things work, and the default would have all the extra bells and whistles. Happy to have it included in any form though :)

@ianschmitz
Copy link
Contributor

Sorry I should have elaborated more. That PR I linked has morphed into a bigger idea of being able to create apps from a template. Templates could be published on npm and referenced using the create-react-app CLI via a specific param.

So for react-testing-library it could be something like create-react-app --use react-testing-library my-app, which would create the app from a template called react-testing-library containing the bits necessary to get the user going with react-testing-library including a best practice App.test.js file, dependencies, etc.

@kentcdodds
Copy link
Contributor Author

I'd be fine with that. I don't have time to work on it myself (I was just bringing up the idea). It does make sense that the default template would be very bare bones and people could opt-into things like a testing library and other features via flags. 👍

@gustavobini
Copy link

Just yesterday, I created a sample app based on create-react-app with react-testing-library just so I could use it "by default" on any new project I create.

Jest by itself is not enough for ui tests. Create-react-app, as an opinionated project, could adopt react-testing-library either by default or by a flag.

@corlaez
Copy link

corlaez commented Mar 3, 2019

The adding as template idea is good, but as @gustavobini says jest is really not enough for react testing and it would make sense to add as a default (because otherwise people will just use enzyme as there is years of articles and docs about it).

@iansu iansu self-assigned this Mar 3, 2019
@kentcdodds
Copy link
Contributor Author

I'd like to bring this up again. It's been several months and we've seen a steady growth in the popularity of React Testing Library in that time, especially among newcomers who are desperately wanting to know how to test their apps. I say let's make this the default.

@iansu
Copy link
Contributor

iansu commented Sep 30, 2019

This sounds reasonable to me. I'd love to get some input from someone on the React team. Dan's on vacation. Maybe @bvaughn?

@kentcdodds
Copy link
Contributor Author

I know that @threepointone has expressed this is something he's interested in as well.

@ianschmitz ianschmitz added this to the 3.x milestone Sep 30, 2019
kentcdodds pushed a commit to kentcdodds/create-react-app that referenced this issue Oct 25, 2019
@lock lock bot locked and limited conversation to collaborators Nov 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants