Learning Behavior-driven Development with JavaScript

Create powerful yet simple-to-code BDD test suites in JavaScript using the most popular tools in the community

Learning Behavior-driven Development with JavaScript

Enrique Amodeo

1 customer reviews
Create powerful yet simple-to-code BDD test suites in JavaScript using the most popular tools in the community
Mapt Subscription
FREE
$29.99/m after trial
eBook
$10.00
RRP $29.99
Save 66%
Print + eBook
$49.99
RRP $49.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$10.00
$49.99
$29.99p/m after trial
RRP $29.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Preview in Mapt

Book Details

ISBN 139781784392642
Paperback392 pages

Book Description

JavaScript is not only widely used to create attractive user interfaces for the Web, but with the advent of Node.js, it is also becoming a very popular and powerful language to write server-side applications. Using behavior-driven development and some common testing patterns and best practices, you will be able to avoid these traps.

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.

Table of Contents

Chapter 1: Welcome to BDD
The test-first approach
BDD versus TDD
Exploring unit testing
The structure of a test
What is a good test?
Summary
Chapter 2: Automating Tests with Mocha, Chai, and Sinon
Node and NPM as development platforms
Configuring your project with NPM
Introducing Mocha
More expressive assertions with Chai
Red/Green/Refactor
Test doubles with Sinon
Summary
Chapter 3: Writing BDD Features
Introducing myCafé
Writing features
Testing asynchronous features
Organizing our test code
Finishing our feature
Summary
Chapter 4: Cucumber.js and Gherkin
Getting started with Gherkin and Cucumber.js
Writing advanced scenarios
Useful Cucumber.js features
Cucumber.js or Mocha?
Summary
Chapter 5: Testing a REST Web API
The approach
Testing the GET order feature
Testing slave resources
Summary
Chapter 6: Testing a UI Using WebDriverJS
Our strategy for UI testing
WebDriverJS
Testing a rich Internet application
Summary
Chapter 7: The Page Object Pattern
Introducing the Page Object pattern
A page object for a rich UI
Summary
Chapter 8: Testing in Several Browsers with Protractor and WebDriver
Testing in several browsers with WebDriver
Welcome Protractor!
Summary
Chapter 9: Testing Against External Systems
Writing good test doubles
Testing against external systems
Summary
Chapter 10: Final Thoughts
TDD versus BDD
A roadmap to BDD
Concluding the book
Next steps?
Summary

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

Authors

Table of Contents

Chapter 1: Welcome to BDD
The test-first approach
BDD versus TDD
Exploring unit testing
The structure of a test
What is a good test?
Summary
Chapter 2: Automating Tests with Mocha, Chai, and Sinon
Node and NPM as development platforms
Configuring your project with NPM
Introducing Mocha
More expressive assertions with Chai
Red/Green/Refactor
Test doubles with Sinon
Summary
Chapter 3: Writing BDD Features
Introducing myCafé
Writing features
Testing asynchronous features
Organizing our test code
Finishing our feature
Summary
Chapter 4: Cucumber.js and Gherkin
Getting started with Gherkin and Cucumber.js
Writing advanced scenarios
Useful Cucumber.js features
Cucumber.js or Mocha?
Summary
Chapter 5: Testing a REST Web API
The approach
Testing the GET order feature
Testing slave resources
Summary
Chapter 6: Testing a UI Using WebDriverJS
Our strategy for UI testing
WebDriverJS
Testing a rich Internet application
Summary
Chapter 7: The Page Object Pattern
Introducing the Page Object pattern
A page object for a rich UI
Summary
Chapter 8: Testing in Several Browsers with Protractor and WebDriver
Testing in several browsers with WebDriver
Welcome Protractor!
Summary
Chapter 9: Testing Against External Systems
Writing good test doubles
Testing against external systems
Summary
Chapter 10: Final Thoughts
TDD versus BDD
A roadmap to BDD
Concluding the book
Next steps?
Summary

Book Details

ISBN 139781784392642
Paperback392 pages
Read More
From 1 reviews

Read More Reviews

Recommended for You

Mastering Web Application Development with AngularJS Book Cover
Mastering Web Application Development with AngularJS
$ 26.99
$ 5.40
Object-Oriented JavaScript - Second Edition Book Cover
Object-Oriented JavaScript - Second Edition
$ 29.99
$ 10.00
Mastering JavaScript Design Patterns Book Cover
Mastering JavaScript Design Patterns
$ 26.99
$ 10.00
MEAN Web Development Book Cover
MEAN Web Development
$ 29.99
$ 3.00
AngularJS Web Application Development Blueprints Book Cover
AngularJS Web Application Development Blueprints
$ 29.99
$ 10.00
AngularJS Web Application Development Cookbook Book Cover
AngularJS Web Application Development Cookbook
$ 29.99
$ 6.00