
- JavaScript
- Intermediate
About this Course
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
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.
9 stepsBehavior 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.
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.
8 stepsNext 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.
7 stepsTeachers
-
Guil Hernandez
Guil is a Full Stack JavaScript and Front End Web Development instructor.
-
Joseph Fraley
Joe is a software engineer and philosopher, trying to leave the world better than he found it. JavaScript was his first love. He's used it building things for non-profits, eCommerce sites, and large scale web applications. You can find him on twitter @joseph_fraley, but he might try to philosophize you.