Assert(js) Speaker Series: thoughts on Testing

Kent C. Dodds
Assert(js) Testing Conf
3 min readJan 15, 2018

--

A few questions and answers about testing in JavaScript

The Assert(js) Conference is just about a month away. I’m really excited about attending, speaking, and workshopping at a conference all about testing JavaScript.

In preparation for the conference, the organizers invited us speakers to answer a few questions about testing. Here are my answers!

What testing tools and/or workflow do you use?

I’ve used pretty much every testing tool for JavaScript there is. I started with QUnit, then used Jasmine, Mocha, sprinkled some Karma to run things, and then I had to figure out how to make things work with babel and webpack, then throwing in code coverage reporting made things really complicated. I even gave a meetup talk called “ES6, Webpack, Karma, and Code Coverage” because it was complicated enough to justify a 45 minute demo/tutorial.

To make a long story short, I eventually bumped into Jest: reborn. I’d used Jest when it was the joker testing framework (pun intended) because it was so slow, but I started to hear it was getting fast. Like… reeeally fast. On top of that, it had all the configuration baked-in. And it has the most incredible watch mode ever.

So, what tool do I use? I’m in love with Jest. ❤️🃏

That said, if I want to run E2E tests, I have to recommend Cypress. No more selenium for me. Cypress.io is where it’s at. Watch this for more on why.

What is one thing would you change in the JS testing ecosystem?

I think that we as a community are in love with poking holes in the world of our applications to make things easier to test by creating Test Doubles/mocks/stubs for anything and everything. Whether it’s shallow rendering a react component or mocking all of its dependencies, we’re reducing our confidence that our applications work properly by mocking the world and testing implementation details.

For more on this, I suggest checking out my blog post: “Write tests. Not too many. Mostly integration.”

A lot of people in the JS world don’t have a lot of experience in testing. How would you recommend they get started?

I think one of the things that makes testing hard is not understanding what’s going on with testing frameworks. That’s why I wrote the blog post “But really, what is a JavaScript test?”

In it I show what a test is, define a few terms, and help folks come to understand what a test is. Once you get that basic concept down, then everything else becomes much easier to understand and use.

P.S. If you like this, make sure to subscribe to my newsletter, follow me on twitter, buy me lunch, and share this with your friends 😀

Also, retweeting this is a great way to share this with your friends:

TestingJavaScript.com Learn the smart, efficient way to test any JavaScript application.

--

--

Kent C. Dodds
Assert(js) Testing Conf

Making software development more accessible · Husband, Father, Latter-day Saint, Teacher, OSS, GDE, @TC39 · @PayPalEng @eggheadio @FrontendMasters · #JS