Libraries, utilities, and tools to enable you to write tests that resemble the way your software is used. @ReactJS, @VueJS, @Cypress_IO, @angular, @fbjest, more
📣 @testing-library/react@13.1.0 just shipped with a new built-in renderHook function that operates similar to @testing-library/react-hooks but with support for React v18 🎉
react-testing-library is growing rapidly. Just hit 1 million downloads per month. 🎉
Raise your hand if you're using one of the Testing Library family of tools: github.com/testing-library
✋
React Testing Library v11 was just published: github.com/testing-library/r…
It should not require any changes for 99% of people and will hopefully make things more stable for everyone :) Enjoy!
Hey there 👋
@kentcdodds just published: "Testing Library Updates: new release, github org, open collective, and twitter account"
testing-library.com/blog/201…
Woo! 🏆🐙🐐🐅🐳🐕🦉🦅
even @codecov bot got so excited about introducing @TestingLib into @MaterialUI that they just had to comment on the PR even if we explicitly disabled comments 😂
Cypress Testing Library v7.0.0-beta.2 was just published and we'd like your help testing it (especially if you use TypeScript): github.com/testing-library/c…
We moved types from DefinitelyTyped to the repo and removed deprecated queries (only find* queries is supported). Try it!
If you're at #ReactRally, keep an eye out for these awesome @TestingLib stickers 👀
🐙 DOM Testing Library
🐐 React Testing Library
🐅 Cypress Testing Library
🐳 React Native Testing Library
🦉 jest-dom
🏆 TestingJavaScript.com
I just refactored the way I fetch data and not one test failed. This shows the power of @TestingLib where you focus on testing the way your software is used rather than implementation details. #reacttestinglibrary#reactjs#testing#webdev
3 facts:
1. I was created so Kent could have something he liked to teach about in a testing workshop. (Just over 1 year ago).
2. There have literally been hundreds of contributors to my codebases.
3. The 🐐 emoji for React Testing Library was chosen completely at random.
3 facts:
1. I'm the 11th of 12 children in my family. (All same parents, no twins. Yes, my mother is a hero).
2. I can't bend my pinkie without bending my ring finger (both hands).
3. I'm working on a fantasy novel and I tweet about it at @kent_writes
So close to my former glory! 🏆
If you haven't updated from react-testing-library to @testing-library/react, get that done! The latest version is definitely cooler 😎 🐐
npmtrends.com/@testing-libra…
ALT npmtrends chart showing @testing-library/react has almost more downloads than react-testing-library
Opportunities to help merge @testing-library/user-event into @testing-library/dom
github.com/testing-library/d…
We need your help if you have typescript experience and if you can help produce documentation examples of the new and updated features.
Not sure about coverage, but to test components I had success with @TestingLib , I jotted my experience with it down timdeschryver.dev/blog/how-t…
There's also dainte, but I haven't used it before.
And lastly, you can always use cypress, as others have already mentioned.
🏆 TestingJavaScript.com is a self-paced workshop that will level-up your testing game and teach you how to configure and use testing tools to get the deploy-confidence you need.
It's 5 hours of high value-to-minute content. Grab your license and supercharge your testing! ⚡
ALT Screenshot of all course modules
ALT Interviews with experts section showing who the interviews are with and the title of the interview
Are you ready to level-up your testing skills?
TestingJavaScript.com is 40% off right now! One week only.
Grab it while it's hot 🔥🔥🔥
Then join us in discord and let's learn together! 🎉
Technically not needed for @TestingLib as Testing Library works in a real browser where this wouldn't be needed.
But if you're like most and running your tests with JSDOM (via @fbjest or otherwise), this could be really useful!!
The copilot.github.com/ AI knows how to write React @TestingLib tests! 🐐 (though it really should be using screen and userEvent...) 😂
ALT Left text that says "Tests without the toil. Tests are the backbone of any robust software engineering project. Import a unit test package, and let GitHub Copilot suggest tests that match your implementation code." Followed by a code example that shows a test written with React Testing Library.
People using React Testing Library, how do you use cleanup? testing-library.com/docs/rea…
1. via setupFilesAfterEnv (or in src/setupTests.js for CRA)
2. import '@testing-library/react/cleanup-after-each' in each test
3. afterEach(cleanup)
4. afterEach(() => {
// stuff
cleanup()
})
New alpha version of @testing-library/cypress published: github.com/testing-library/c…
Please give it a test drive!
1. npm install @testing-library/cypress@alpha
2. find/replace `.get` with `.find` in your `cypress/` directory
Everything should still work. Let us know if it doesn't!
This is one of the best parts of @TestingLib! You learn it with React (or any other framework), then you can use it with Vue (or any other framework). BYOF (bring your own framework). It's fabulous.
Awesome! Even better than the mutation observer shim is to use the latest version of jsdom with either the latest version of jest or jest-environment-jsdom-sixteen.
Download numbers show me a bit behind enzyme but catching up fast.
Enzyme's download numbers are still growing, but the growth is slowing and my growth is accelerating.
If you're still using #enzyme over @TestingLib for your @reactjs codebase then you're going to have a massive headache migrating to functional components.
1/n
"There hasn't been a library more intuitive, easy to set up and more beginner friendly. In some occasions, it has been even a great way to break in a developer into a new project." @aromanarguello on @TestingLibmedium.com/@aromanarguello/g…
ALT “There hasn’t been a library more intuitive, easy to set up and more beginner friendly. In some occasions, it has been even a great way to break in a developer into a new project.…” from “Getting started with Jest + react-testing-library” by Alejandro Roman.
This is great!
One thing that I'd recommend is to make sure that your tests are isolated (related: kentcdodds.com/blog/test-iso…). I would have written all of that as a single test (kcd.im/trophy). Just some thoughts :) Thanks for sharing your knowledge! - @kentcdodds
That merge didn't happen. Hit a ship stopper. For now they'll remain separate. However user event did get an update that was pretty cool.
Also, we went the opposite direction and now everything is sync (for now)
Is there a reason no alt is on the image? You'll want an alt on the image to make it accessible to screen readers. With that you can ditch the test id and use getByAltText
I'm guessing that code sample was just an example, but in case it's not, make sure you have test isolation! kentcdodds.com/blog/test-iso… (you'd need a render call in the test)