Istanbul is a module that can ensure that tests are fully covering your application. In this Node.js tutorial, Alex Banks will demonstrate how to run Istanbul in combination with mocha to generate code coverage reports, as well as how to make adjustments for better coverage.
- View Offline
- Exercise Files
- Istanbul is a node module that we can use to…generate code coverage reports.…Code coverage reports tell us how many…lines of code our tests actually cover.…Let's go ahead and navigate to the terminal…and install istanbul globally.…Sudo npm install -g istanbul.…So once we have istanbul installed globally,…we can use it from anywhere.…Istanbul will work with mocha as well,…so we can generate code coverage reports…from our mocha tests.…The command to actually generate the code…coverage report with mocha is istanbul...…
cover _mocha, and the reason that…we need to call _mocha is because, actually,…when we call mocha, mocha forks the _mocha process,…so both of these executables are there,…but istanbul won't work with regular mocha,…we need to use the _mocha process.…So, when I do this, this will actually run our test…that we have developed in this chapter,…and in addition to running our test,…and we can see that five are passing,…we have generated a code coverage report,…and we can see a summary of that report here.…
Alex Banks shows how to install Node.js on a Mac or PC and work with the Node.js core: the global object, event loop, http module, and file system. Then he covers reading and writing data, streaming data, making http requests, and working with the node package manager (npm). In the final chapters, he shows how to start sessions on web servers, communicate with web servers and clients with WebSockets, use the Express framework to develop applications, and test and debug Node.js code. Want to speed up your Node.js workflow? Check out the tutorials on automating tasks with Grunt and npm scripts.
- What is Node.js?
- Installing Node.js
- Understanding the global object and global timing
- Importing the core modules
- Handling events
- Creating child processes
- Reading, writing, and removing files
- Working with file streams
- Making http requests
- Serving files and JSON data
- Installing npm, the node package manager
- Working with Express, the web server framework
- Using WebSockets
- Testing and debugging Node.js code
- Working with Grunt and Browserify
- Automating tasks with npm scripts
Skill Level Intermediate
1. What Is Node.js?
2. Installing Node.js
3. Node Core
4. Node Modules
5. The File System
6. The HTTP Module
7. Node Package Manager
Installing npms locally4m 4s
8. Web Servers
Creating a WebSocket server8m 30s
10. Testing and Debugging
11. Automation and Deployment
Next steps2m 4s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.