Confidently Shipping Code
Why I care about testing
Have you read the book “Start With Why”? If you haven’t, I recommend it. At least watch the TED talk. The premise of the idea is that “People won’t truly buy into a product, service, movement, or idea until they understand the WHY behind it.” This concept hit home with me when I watched that talk and then read the book a few years ago, and it’s shaped the way I communicate with you in my blog posts, talks, workshops, and courses.
I’d like to share my “why” about testing with you and invite you to consider what your own “why” might be.
Like many people, at the start of my career I didn’t understand automated software testing. I was introduced to it by my friend Joe Eames, who was then fighting an uphill battle at the company where we both worked to get people to write tests. I was an intern at the time, and he took me under his wing a few times to teach me about automated testing. I thought it was pretty neat, but he moved on to another job before I really got testing ingrained in my workflow.
Later, when I started writing my first JavaScript library (geniejs), I realized quickly that spending time to manually verify that everything’s working, every single time I fixed a bug or added a new feature, was pretty annoying. I decided to learn to test and write tests for my library. (The tests have been through a few testing framework refactorings, but they’re still largely the same as when I originally wrote them all those years ago). Investing time into testing my library ended up saving me a TON of time, and I was able to integrate testing into my workflow.
I remember when I was actively working on angular-formly, I had a coworker who needed a new feature. It was a simple feature, so he sat by me and watched as I wrote the test, implemented the feature, and pushed the commit to trigger a release. He was shocked that I could rely on the tests so much that I was confident I didn’t break anything. That was when it really occurred to me that testing had become more than a default workflow for saving time. It was a mechanism for giving me confidence.
At the time of this writing, I have 111 packages published on npm. Pretty much every one of those packages has 100% code coverage, meaning every line is run in the tests. I don’t think I could possibly maintain them any other way. My libraries have received contributions from thousands of people. When someone opens a pull request with changes to one of my libraries, I have a continuous integration service (TravisCI) that kicks off to run all the tests. Sometimes it’s been months or even years since I’ve touched the code. Past Kent, who had just barely written the code, probably knew instantly whether something broke. Present Kent? He usually has no idea, and it would take me a lot of time to evaluate. Having the tests in place is like Past Kent telling Present Kent: “It’s ok. This is very unlikely to break anything.” The tests save me time, and they give me—and all the users of my libraries—a great amount of peace of mind.
So why do I write tests? I write tests because they allow me to accomplish more than I could otherwise. I now have thousands of Kents in the form of automated tests telling me whether changes are breaking use cases. With that venerable army of robots, I’m able to rest easy and get more accomplished.
Now, I want to ask you a question: Why do you want to learn testing? Is it to further your career?Did a specific incident (i.e. a bug—yup, we’ve all been there) happen that prompted a need? Do you (like me) simply want to get more done, with more peace of mind?
Now my next question: What has been holding you back from starting?
Conclusion
Whether you’re already testing, or you’re interested in getting started, I’ve got something coming that I think you’ll love. Especially if you’ve struggled to know what to test. I’ve been working hard putting together the most comprehensive work of my life, and I think it’ll knock your socks off. Stay tuned.
Looking for a job? Looking for a developer? Check out my job board: kcd.im/jobs
Things to not miss:
- Professional React Training from Ryan Florence - I strongly recommend you look. Ryan’s doing a tour to 12 cities in the US!!
- DevTips with Kent - I’m still doing (week)daily livestreams that hundreds of people watch :) Don’t miss it!
Some tweets from this last week:
> Some tools I used today that made my life way easier: > > - emotion.sh > - docz.site > - now.sh > - git.io/babel-plugin-macros > - lernajs.io > > So nice! – Sep 21, 2018
> Hey everyone! @Cypress_io is out of beta and they officially announced that cross-browser support is coming INCLUDING IE11!!!!!!!! www.cypress.io/blog/2018… – Sep 21, 2018
> I was on @ReactPodcast! Episode 21: reactpodcast.com/21 “Delete Your Components with Kent C. Dodds” > > We talk about how I got into programming, where downshift came from, how to simplify your react applications, some people I love, and more. Enjoy! – Sep 18, 2018
> Ok… You’re building a component library. Which do you use for things like margin/padding/font-size/etc? – Sep 21, 2018 (The thread here is very enlightening! I’m thinking rem
is the way to go for most things. I especially appreciated this thread from Nicole Sullivan).
> > Next.js can even server-render WebAssembly > > OH WOW! nextjs.org/blog/next-7 – Sep 20, 2018
> My wife just helped me talk through some of the plot of my novel series and OH WOW! I can’t wait to read this thing! AHHH! This story is coming together in such awesome ways. I hope I can do this story justice for you. – Sep 22, 2018
This week’s blog post is “How I am so productive”. It’s the published version of my newsletter from 2 weeks ago. If you thought it was good, go ahead and give it some claps (👏x50) and a retweet:
P.S. If you like this, make sure to subscribe, follow me on twitter, buy me lunch, support me on patreon, and share this with your friends 😀
👋 Hi! I’m Kent C. Dodds. I work at PayPal as a full stack JavaScript engineer. I represent PayPal on the TC39. I’m actively involved in the open source community. I’m an instructor on egghead.io, Frontend Masters, and Workshop.me. I’m also a Google Developer Expert. I’m happily married and the father of four kids. I like my family, code, JavaScript, and React.