Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed JavaScript Unit Testing!
You have completed JavaScript Unit Testing!
Preview
In this video, you'll learn to write a test suite using the 'describe()' function, and a test spec using the 'it()' function.
Resources
Video review
- A test suite is a block of unit tests that are all closely related; they test the same function or similar parts of our code base
- We introduce a test suite in Mocha using
describe() - Each individual unit test is sometimes called a “spec”
- Mocha makes it natural to write specs by containing them in a function called
it() - To use Chai's
expectmethod, import Chai at the top of your file:var expect = require('chai').expect
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Remember, a Test suite is a block of
unit tests that are all closely related
0:00
because they test the same function or
they test similar parts of our code base.
0:04
We introduce a test suite
in Mocha using describe.
0:09
Describe is a function
that takes two arguments.
0:19
A string and another function.
0:22
We used a string to describe
what the suite will cover.
0:26
So, for example, let's write a test for
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up