JavaScript Unit Testing Course

Go to class
Write Review

Free Online Course: JavaScript Unit Testing Course provided by Treehouse is a comprehensive online course, which lasts for 3-4 hours worth of material. The course is taught in English and is free of charge. JavaScript Unit Testing Course is taught by Guil Hernandez.

Overview
  • In this course, you’ll use Behavior Driven Development to write unit tests for your functions with the JavaScript testing framework Mocha.js. Writing unit tests will help you improve your code before you even start writing it. You’ll have fewer problems, and better understand the problems you do have.

    What you'll learn

    • Different Types of Testing
    • Behavior Driven Development
    • Mocha and Chai
    • Writing Testable Code

Syllabus
  • Introducing Unit Testing

    This stage covers different kinds of automated testing, especially “unit testing”. You'll learn what a unit test is, when you should write them, and why having unit tests is so useful.

    Chevron 9 steps
    • Introduction

      1:27

    • Proving Our Code Works

      4:22

    • Running Your First Automated Test

      4:13

    • Running an Automated Test

      1 objective

    • Different Types of Testing

      3:16

    • Behavior Driven Development

      2:47

    • Red, Green, Refactor

      7:56

    • Greater Expectations

      10:13

    • Review: Types of Testing

      8 questions

    Behavior Driven Development with Mocha & Chai

    The real power of unit tests is when you use them to help you write code from the start. In this stage, you'll use Mocha.js and Chai to write tests about how your functions should behave as an outline for your actual code.

    Chevron 13 steps
    • Getting Started with Mocha and Chai

      3:16

    • General Structure of Test Files

      4:10

    • Setting Up Mocha

      4 questions

    • Installing Mocha

      1 objective

    • Installing Chai

      1 objective

    • Test Suites and Test Specs (describe and it)

      3:34

    • Mocha Chai Basics

      4 questions

    • Writing Our First Test Suite

      14:49

    • Writing Our First Test Suite - Part 2

      8:15

    • Challenge: Expanding Our Expectations

      9:57

    • Answer: Expanding Our Expectations

      12:05

    • A Testing Test!

      1 objective

    • Assert Your Knowledge

      5 questions

    Improving Our Tests

    Just like your application code, you should keep your tests DRY and tidy. This stage explores handy ways to avoid repeating code. You'll also expand your tests to build your confidence in the code you've written so far.

    Chevron 8 steps
    • Making Tests Easier with Fixtures: Setup

      7:41

    • Making Tests Easier with Fixtures: Teardown

      3:39

    • Before and After

      4 questions

    • Covering Edge Cases

      10:55

    • Catching an Error

      1 objective

    • Challenge: Writing Testable Code

      2:00

    • Answer: Writing Testable Code

      4:36

    • Testable Logic

      4 questions

    Next Steps

    In this stage, you'll learn how Mocha can output your test results in a browser. You'll also learn testing features that simplify testing in bigger projects.

    Chevron 7 steps
    • Changing Mocha’s Reporter

      3:06

    • Outlining Your Test Suite

      4:31

    • Watching Test Files

      5:56

    • Outline, Watch, Report

      6 questions

    • Mocks and Stubs

      9:30

    • Testing Asynchronous Code

      8:54

    • Done!

      5 questions