This book will show you how to do BDD in a practical way. We will start with a basic introduction of what BDD is and why the classical approach to testing has failed. Afterwards, we will dive directly into an introduction to Node.js, Mocha, and Sinon.JS. Finally, we will cover more advanced subjects such as how to write a fast and effective test suite for a RESTful web API, and how to do the same with a rich UI using Cucumber.js and Protractor.
This book will give you great insight into how to architect your system to make it more testable and modular, but at the same time avoid the nightmare of abusing mock objects.
What You Will Learn
Understand the basic concepts of BDD and how it is different from classic unit testing
Divide your system into different modules that can be tested separately, but at the same time not falling into the trap of unit testing
Use Mocha, Sinon.JS, and Chai to write expressive BDD features
Implement Cucumber.js to automate tests written in Gherkin so that your stakeholders can understand them
Discover how to test asynchronous systems, either based on callbacks or promises
Test a RESTful web API and a rich UI using WebDriverJS and Protractor
Refactor and keep your test code base maintainable using best practices and patterns such as PageObject
Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.