Test-Driving JavaScript Applications

Rapid, Confident, Maintainable Code

by: Venkat Subramaniam

Published 2016-10-05
Internal code vsjavas
Print status In Print
Pages 362
User level Intermediate
Keywords JavaScript, testing, asynchronous, Node.js, Express, MongoDB, jQuery, AngularJS, Karma, Mocha, Chai
Related titles

Automate with Grunt
Node.js the Right Way
Async JavaScript

ISBN 9781680501742
Other ISBN Channel epub: 9781680504903
Channel PDF: 9781680504910
Kindle: 9781680502299
Safari: 9781680502305
Kindle: 9781680502299
BISACs COM051260 COMPUTERS / Programming Languages / JavaScript
COM051330 COMPUTERS / Software Development & Engineering / Quality Assurance & Testing
COM051330 COMPUTERS / Software Development & Engineering / Quality Assurance & Testing

Highlight

Debunk the myth that JavaScript is not easily testable. Whether you use Node.js, Express, MongoDB, jQuery, AngularJS, or directly manipulate the DOM, you can test-drive JavaScript. Learn the craft of writing meaningful, deterministic automated tests with Karma, Mocha, and Chai. Test asynchronous JavaScript, decouple and properly mock out dependencies, measure code coverage, and create lightweight modular designs of both server-side and client-side code. Your investment in writing tests will pay high dividends as you create code that’s predictable and cost-effective to change.

Description

Design and code JavaScript applications with automated tests. Writing meaningful tests is a skill that takes learning, some unlearning, and a lot of practice, and with this book, you’ll hone that skill. Fire up the editor and get hands-on through practical exercises for effective automated testing and designing maintainable, modular code.

Start by learning when and why to do manual testing vs. automated verification. Focus tests on the important things, like the pre-conditions, the invariants, complex logic, and gnarly edge cases. Then begin to design asynchronous functions using automated tests. Carefully decouple and mock out intricate dependencies such as the DOM, geolocation API, file and database access, and Ajax calls to remote servers.

Step by step, test code that uses Node.js, Express, MongoDB, jQuery, and AngularJS. Know when and how to use tools such as Chai, Istanbul, Karma, Mocha, Protractor, and Sinon. Create tests with minimum effort and run them fast without having to spin up web servers or manually edit HTML pages to run in browsers. Then explore end-to-end testing to ensure all parts are wired and working well together.

Don’t just imagine creating testable code, write it.

Contents and Extracts