Check out a free preview of the full JavaScript Testing Practices and Principles course

The "Introduction" Lesson is part of the full, JavaScript Testing Practices and Principles course featured in this preview video. Here's what you'd learn in this lesson:

Kent C. Dodds introduces the course as a primer for testing and testing frameworks so that students gain confidence in testing, and the ability to write tests that are maintainable. Ken also covers cloning the git repository and sets the routine for the course. Note: The repository has moved. The correct location is below.

Preview
Close

Transcript from the "Introduction" Lesson

[00:00:01]
>> Speaker 1: Yeah, hi, everyone. So my name is Kent C Dodds and this is some information about me. Each one of these little things is linked including a cute picture of my puppy. My oldest is not even six yet, so I don't know why we got a puppy, but we did.

[00:00:19]
And now, we're happy with her. But yeah, so my slides are right here, kcd.im/tp-slides. And you can get all of links and stuff. There isn't a whole lot to my slides beyond this. There are a couple of useful things and some resources that I link to. But for the most part, most of our time is gonna be spent in the repo anyway, so which is like open source, you'll have access to that forever.

[00:00:46]
Okay, cool. So I like to set up expectations so that you're not like waiting for something and then it never comes. So let's talk about what this talk is. We're gonna be talking about the fundamentals behind tests and testing. So we're actually going to write a testing framework in Assertion Library.

[00:01:07]
That's the first thing we're gonna do today, so that you really get understanding of what testing really is. Another thing that I didn't mention, but I probably should is this is all JavaScript stuff. So if you're not experienced with JavaScripts at all, you're gonna struggle a little bit.

[00:01:25]
I had somebody come to a workshop like this recently who knew nothing about JavaScript and it was a little bit of a struggle for them to do the exercises. So hopefully, you're familiar with JavaScript. But if you're not, then get your friend to come and help you with the syntax.

[00:01:41]
JavaScript is the best language anyway, so you should learn it. So we're gonna talk about different forms of testing not all forms of testing. There are many, the two that we are focusing on today are unit and integration testing. This is more like practices and principles, so lots of these things can apply to various forms of testing, these are just the two that we'll be focusing on today.

[00:02:07]
And we'll definitely cover test doubles or mock spies or stubs, whatever you wanna call those things we'll be talking about that, what those really are, and in what situations they're useful. We'll talk about test driven development. We're not gonna be talking about all of the different methodologies of testing, but TDD is one that I found to be pretty useful on certain situations.

[00:02:33]
And then yeah, just hopefully, this gives you some core principles to help you write tests that'll give you confidence and also are maintainable. So I'm gonna try and avoid technology-specific stuff. We're gonna be using specific frameworks and stuff. And so there, you will need to learn at least the assertion library and how to use the framework a little bit.

[00:02:57]
But the technology-specific stuff is from my other workshop with testing react We're not gonna configure any tools, it's all preconfigured for you and everything. And testing is one subject that has a huge variety of opinions and that is not lost on me, I have a lot opinions based off of my experience testing.

[00:03:23]
And I know several people, I just spoke at a conference all about testing JavaScript. And it was like every other talk was disagreeing with the previous one. It was so many opinions about testing. So there are tradeoffs everywhere in software. In particular with testing, there are tons of tradeoffs.

[00:03:43]
And so, I'll be giving you my opinions of things that I've seen that have made it easier for me to maintain tests and that give me confidence that I'm looking for. And, like I said earlier, we're not covering all the forms of testing, just a select few. So if you haven't set up the workshop, make sure that you do that, it's going to take a fair amount of time to set it up, just because that's the way it is.

[00:04:09]
The workshop is pretty big. It's actually an application where I'm trying to balance the line between totally practical but not too confusing and domain specific. And so you are installing an app, but it also has this other directory that has some other stuff in it for specific examples.

[00:04:33]
So yeah, this may take a fair amount of time for you to install, but once that's done you should be all set and ready to go. If you are struggling with that a little bit, I'll be in the chat and in here helping people out during exercises and stuff.

[00:04:48]
Yeah, for many of the exercises, not all of them, but for many of the exercises, there's a test at the bottom that has a link to elaboration and feedback. This is scientifically proven that when you reiterate the things you have been taught, that you'll remember those things better.

[00:05:07]
And so, that is why I have this form, that's why I added it to my workshops so it gives you an opportunity to type out what it is that you learned from this exercise. And that will just help solidify things in your mind. It's kinda like-
>> Speaker 2: If you're watching it as a course, use the notes feature and take notes to yourself.

[00:05:28]
>> Speaker 1: Yeah, thanks, Mark. Yeah, I gotta think about that, too. Feel free to still submit the feedback if you want to. But yeah, the notes feature would be a good place to take those notes as well. And then, if you have any questions for me that aren't really related to this, I do have an ask me anything on GitHub.

[00:05:47]
Several hundreds of questions on there that you can read through and ask additional questions if they're not relevant to today's subject. And then, I tweet sometimes, actually I tweet all the time. I'm constantly tweeting all the time. So if you're interested in JavaScript, React and how cute my dog is.

[00:06:08]
I don't tweet about my dog too much. Okay, so the routine that we're gonna go through is I'm gonna demo something, a principle or practice, and well, this is a general routine, not all of them will follow this. But in general, I'll demo something. I'll introduce you to the exercise and then set you loose on the exercise.

[00:06:29]
I'll show you how to run the test and everything to get that exercise going. If you can, pair program with somebody on the exercise. You don't both have to be working through the exercise on your computer. You can like be on one person's computer. So if you're interested in doing that, I recommend it because it's a really great way for both of you to solidify what you're understanding.

[00:06:50]
You have to talk through what your assumptions are, and you can correct each other's assumptions. So yeah, pair programming in the exercises is a great way to solidify your understanding there. Make sure to fill out the elaboration, that'll help you solidify things. For some of the exercises, there's a bonus test that you can implement additional stuff, implement additional tests.

[00:07:15]
Look for opportunities to help others, that will, so let me let you in on a little secret. So when I give these workshops, this is actually just a part of my learning process. So I'm in the process of learning testing, in the process of learning React and a really important part of my process is to teach what I'm learning to other people, and that's how I solidify my understanding.

[00:07:40]
So I wouldn't have had nearly as much experience with this stuff if I didn't have to prepare this workshop to give to you all. And I wanna work really hard to make sure that it's really great content. And so, when you try to take the things that you've learned and teach it to other people, it will help solidify that understanding in your mind as well, clear up some misconceived assumptions that you have and that kind of thing.

[00:08:09]
So if you notice somebody is struggling with something, then look for an opportunity to help them. And if you notice something weird in the repository, a typo or anything like that, feel free to make a pull request. It's totally open source and several people have actually done that.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now