Preface

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

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

The Jasmine JavaScript Testing book is a practical guide to writing and automating JavaScript testing for web applications. It uses technologies such as Jasmine, Sinon.JS, RequireJS, and Grunt.

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), passing through the concepts of maintainable browser code, and concluding with a full refactoring to a Backbone.js application with RequireJS dependency management, 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 test.

Chapter 2, Your First Spec, helps you learn the thought process behind thinking in 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. It also demonstrates how Jasmine matchers work, and how you can create one of your own to improve your tests' code readability.

Chapter3, Testing Frontend Code, covers some patterns in writing maintainable browser code. You will learn about thinking in 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 a 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 NodeJS, 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 perform behavior checking.

Chapter 6, Light Speed Unit Testing, helps you learn about the issues with AJAX testing, and how you can make your tests run faster by using Stubs or Fakes (such as SinonJS Fake Server).

Chapter 7, Testing Backbone.js Applications, presents the four base abstractions of Backbone.js, and how you can write tests to a Backbone.js application. You will learn about what to test, and not to test, when using Backbone.js.

Chapter 8, Build Automation, presents you the power of automation. You will learn about RequireJS, and how it helps you organize the dependencies of large JavaScript applications. You will start to think in 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. Then you are going to use PhantomJS to run all your tests without a browser window, and even how to make them run automatically on any file change.

Chapter 9, Conclusion, talks about the future of testing and tooling in the JavaScript ecosystem.

Chapter 10, Testing jQuery Plugins, presents the concept of jQuery plugins and how you can use Jasmine do drive the development of a plugin of your own. This bonus chapter is available at the following link: http://www.packtpub.com/sites/default/files/downloads/7204OS_ Testing_jQuery_Plugins.pdf.

Chapter 11, Continuous Integration with Travis CI, teaches you how to set up a continuous integration environment for a JavaScript application using Travis CI. This bonus chapter is available at the following link: http://www.packtpub.com/sites/default/files/downloads/7204OS_Continuous_Integration_with_Travis_CI.pdf.

Chapter 12, The Future: Jasmine 2.0, gives you a glimpse on what are the major changes and how to roll an incremental migration to the upcoming Jasmine 2.0 release. This bonus chapter is available at the following link: http://www.packtpub.com/sites/default/files/downloads/7204OS_The_Future _Jasmine_2_0.pdf.

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

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