1 00:00:00,000 --> 00:00:04,678 [MUSIC] 2 00:00:04,678 --> 00:00:05,872 Hello world. 3 00:00:05,872 --> 00:00:08,729 Andrew here, JavaScript developer, lifelong learner and 4 00:00:08,729 --> 00:00:10,550 teacher here at Treehouse. 5 00:00:10,550 --> 00:00:14,990 In this workshop, we're going to be talking about code coverage. 6 00:00:14,990 --> 00:00:18,150 Code coverage is the healthy development practice that describes how 7 00:00:18,150 --> 00:00:23,660 much of a program source code is executed during the execution of the test sweep. 8 00:00:23,660 --> 00:00:26,300 So, why should you do code coverage? 9 00:00:26,300 --> 00:00:29,750 Well, it helps to see how much testing you're doing in your project. 10 00:00:29,750 --> 00:00:33,610 It helps you spot parts in your code that the tests are missing. 11 00:00:33,610 --> 00:00:36,950 It's also good to show business stakeholders in a project, 12 00:00:36,950 --> 00:00:40,840 whether they are a project manager or clients on a project. 13 00:00:40,840 --> 00:00:43,100 If you're publishing NPM modules, 14 00:00:43,100 --> 00:00:47,010 showing your code coverage gives developers confidence in your module. 15 00:00:47,010 --> 00:00:51,130 For example, you'd expect a module with 100% code coverage 16 00:00:51,130 --> 00:00:54,120 should work better than a module with only 10%. 17 00:00:54,120 --> 00:00:58,630 While software with more code coverage may instill more confidence than software 18 00:00:58,630 --> 00:01:00,690 without code coverage, 19 00:01:00,690 --> 00:01:04,880 it doesn't guarantee the quality of the tests that test the source code. 20 00:01:04,880 --> 00:01:08,698 For example, there may be sets in edge cases missing. 21 00:01:08,698 --> 00:01:10,986 Because test edge cases could be missing, 22 00:01:10,986 --> 00:01:14,230 there could be some bugs that could still happen. 23 00:01:14,230 --> 00:01:19,180 In other words, having 100% code coverage doesn't ensure good software. 24 00:01:20,260 --> 00:01:24,150 The till we'll be using for code coverage is called Istanbul. 25 00:01:24,150 --> 00:01:27,390 Istanbul is a node module that's compatible with testing libraries 26 00:01:27,390 --> 00:01:29,230 like Mocha and Jasmine. 27 00:01:29,230 --> 00:01:32,810 Istanbul can generate code coverage reports that are compatible with 28 00:01:32,810 --> 00:01:37,230 online services like Coveralls and Codecov. 29 00:01:37,230 --> 00:01:40,740 You can share your open source projects code coverage publicly, or 30 00:01:40,740 --> 00:01:44,020 your internal or client projects privately. 31 00:01:44,020 --> 00:01:48,960 In this workshop, we're going to set up code coverage in a simple calculator app. 32 00:01:48,960 --> 00:01:53,355 Feel free to clone the app now or download the zip file attached to this video.