From the course: JavaScript: Test-Driven Development (ES6)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Writing and running basic tests

Writing and running basic tests - JavaScript Tutorial

From the course: JavaScript: Test-Driven Development (ES6)

Start my 1-month free trial

Writing and running basic tests

- So now that we've learned a little bit more about unit tests, it's time to write and run our first unit test using Mocha and Chai. The first thing we're going to do is set up a new directory, we'll be writing our code. So go into whatever parent directory you'd like and create a new folder and call it, tdd-es6, or whatever else you want. And once we're in this directory, we're going to initialize a new npm project and to do that, open up a terminal and make sure you're inside this tdd-es6 folder that we just created, and run npm init -y and hit enter. And once that run successfully, it's time to install the Mocha and Chai libraries we'll be using for testing. To do that, type npm install - -save-dev mocha chai, hit enter. That'll run for a little bit and after it's done, let's create a directory called, source. And inside this directory, we're going to create two files. The first one is going to be called…

Contents