Testing is an essential part of development. When used properly, testing can catch and identify issues with your implementation code before you deploy it to users. Instead of testing every function manually, developers automate their tests with a test framework.

Developers use test frameworks to organize and automate tests that provide useful feedback when errors occur. In this lesson we will use the Mocha test framework to write tests against JavaScript methods.

In this lesson you will:

  • Learn to write a basic Mocha test suite
  • Use Node’s assert.ok method to verify the expected output of your code
  • Understand and apply the four phases of a test to create an expressive testing suite
  • Evaluate the quality of your tests against the characteristics of a good test



A complete test suite is provided for you on the right. Run the suite and view its output by typing npm test in the terminal and hitting Enter.

Can you match the test output in your terminal to strings in index_test.js?

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?