Learn
Write Expressive Tests
Introduction

A good test framework is fast, complete, reliable, isolated, maintainable, and expressive. In this lesson you will learn how to use Node’s assert library to write more expressive tests.

An expressive test is easy to read and descriptive, making it useful as a form of documentation for your implementation code. One way to make a test more expressive is clarifying its verify phase — the step where expected outcome is compared to actual outcome.

Node.js provides a library called assert with methods that help you write more expressive verification code. You can use the methods in this library in place of conditional statements to write less code and use human-readable language. It can be used within the Mocha testing framework, and you will be using both throughout this lesson.

Instructions

1.

An assertion has been provided within a Mocha describe - it block. Run the Mocha test suite by typing npm test in the terminal and hitting Enter.

Review the output and move on to the next exercise.

Folder Icon

Sign up to start coding

Already have an account?