Рет қаралды 31,598
In this video we'll take a look at Unit testing with Mocha and Chai.
Get the code here: github.com/codebubb/unit-test...
You can either see the completed code or at the start of the lesson
git checkout lesson-01-start
git checkout lesson01-complete
Unit testing with Mocha and Chai
-----------------------------------------------------
00:00 Introduction
00:50 Installing dependencies
01:50 Setting up
03:23 Writing first unit test
06:01 Chai
07:26 Useful unit tests
11:32 Exercise
13:05 Using nyc
- Follow Me -
Twitter: / codebubb
Facebook: / juniordevelopercentral
Blog: www.juniordevelopercentral.com/
- Thanks! -
This JavaScript tutorial is intended as a beginners guide to unit testing with Mocha and Chai.
In the lesson, we'll take a look at getting a project set up with the Mocha and Chai dependencies and we'll also install nyc for code coverage.
To start off we'll write your first unit test and see how a simple function can be testing with the basic built in Node.js Assert package and then we'll swap this out for the more power assertions available in the Chai library.
Once we've written our first unit test, we'll expand on this to create a more robust function and cover different scenarios of how the function should behave.
I'll then set you a challenge to see if you can can setup a new function and write unit tests with Mocha and Chai.
Once we've got some good unit tests set up we'll take a look at how you can use nyc to generate code coverage reports which will give you an overview of how much of your code you have covered and also which bits of code still need to be tested. Channel Handle @codebubb