Preface

This book is about being a better JavaScript developer. So, throughout the chapters, you will not only learn about writing tests in the Jasmine 'idiom', but also about the best practices in writing software in the JavaScript language. It is about acknowledging JavaScript as a real platform for application development and leveraging all its potential. It is also about tooling and automation and how to make your life easier and more productive.

Most importantly, this book is about craftsmanship of not only working software, but also well-crafted software.

Jasmine JavaScript Testing, Second Edition is a practical guide to writing and automating JavaScript testing for web applications. It uses technologies such as Jasmine, Node.js, and webpack.

Over the course of the chapters, the concept of test-driven development is explained through the development of a simple stock market Investment Tracker application. It starts with the basics of testing through the development of the base domain classes (such as stock and investment), passes through the concepts of maintainable browser code, and concludes with a full refactoring to a React.js application build on ECMA Script 6 modules and automated build.

What this book covers

Chapter 1, Getting Started with Jasmine, covers the motivations behind testing a JavaScript application. It presents the concept of BDD and how it helps you to write better tests. It also demonstrates how easy it is to download Jasmine and start coding your first tests.

Chapter 2, Your First Spec, helps you learn the thought process behind thinking in terms of test-driven development. You will code your very first JavaScript functionality driven by tests. You will also learn the basic functions of Jasmine and how to structure your tests. Also demonstrated, is how Jasmine matchers work and how you can create one of your own to improve your tests' code readability.

Chapter 3, Testing Frontend Code, covers some patterns in writing maintainable browser code. You will learn about thinking in terms of components and how to use the module pattern to better organize your source files. You will also be presented with the concept of HTML fixtures and how you can use it to test your JavaScript code without requiring your servers to render an HTML. You will also learn about a Jasmine plugin called jasmine-jquery and how it can help you write better tests with jQuery.

Chapter 4, Asynchronous Testing – AJAX, talks about the challenges in testing AJAX requests and how you can use Jasmine to test any asynchronous code. You will learn about Node.js and how to create a very simple HTTP server to use as a fixture to your tests.

Chapter 5, Jasmine Spies, presents the concept of test doubles and how to use spies to do behavior checking.

Chapter 6, Light Speed Unit Testing, helps you to learn about the issues with AJAX testing and how you can make your tests run faster using stubs or fakes.

Chapter 7, Testing React Applications, introduces you to React, a library to build user interfaces, and covers how you can use it to improve the concepts presented in Chapter 3, Testing Frontend Code, to create richer and more maintainable applications, of course, driven by tests.

Chapter 8, Build Automation, presents you with the power of automation. It introduces you to webpack, a bundling tool for frontend assets. You will start to think in terms of modules and their dependencies, and you will learn how to code your tests as modules. You will also learn about packing and minifying the code to production and how to automate this process. Finally, you are going to learn about running your tests from a command line and how this can be used in a continuous integration environment with Travis.ci.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset