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 - JavaScript Tutorial
From the course: JavaScript: Test-Driven Development (ES6)
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
The purpose of unit testing3m 51s
-
(Locked)
JavaScript frameworks for unit testing2m 36s
-
(Locked)
Writing and running basic tests2m 8s
-
(Locked)
Testing basic functions5m 23s
-
(Locked)
Testing asynchronous functions3m 33s
-
(Locked)
Modifying existing functionality3m 17s
-
(Locked)
To mock or not to mock?3m 58s
-
(Locked)
Challenge: Given criteria, write unit tests3m 14s
-
(Locked)
Solution: Given criteria, write unit tests10m 29s
-
-
-
-
-
-
-