Preface

All programmers want their code to work the way they intended. Jasmine, a popular testing framework for the JavaScript programming language, allows you to achieve that goal. Through coded specifications, Jasmine helps make your JavaScript work exactly how it’s supposed to. In this book, we’ll explore Jasmine in detail, from its basic concepts to its advanced features.

This book aims to explain the concepts of testing and test-driven development, as well as why they’re useful. It then aims to dive into Jasmine and explain how it can help programmers test their JavaScript code. By the end of this book, I aim to give readers an understanding of Jasmine’s concepts and syntax.

Who Should Read This Book

This book is intended for programmers who are familiar with some more advanced JavaScript features, such as closures and callbacks, and who have a general understanding of JavaScript’s prototype system. If you are interested in learning how to write reliable JavaScript code, this is the book for you.

Jasmine is useful when building a maintainable and scalable JavaScript application, either in a browser or on a server. It can help ensure that a browser’s client-side data models are performing properly, or that a server is correctly serving pages.

Jasmine is also useful for building reliable JavaScript libraries. It can help ensure that the exposed API of your library matches what you intend it to match.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Tip

This icon signifies a tip, suggestion, or general note.

Using Code Examples

This book is here to help you get your job done. In general, if this book includes code examples, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “JavaScript Testing with Jasmine by Evan Hahn (O’Reilly). Copyright 2013 Evan Hahn, 978-1-4493-5637-8.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

Safari® Books Online

Note

Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://oreil.ly/JS_Jasmine.

To comment or ask technical questions about this book, send email to .

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments

Thanks to RockMelt for asking me to learn Jasmine.

Thanks to Pivotal Labs for creating Jasmine.

Thanks to my parents for their constant support.

Get JavaScript Testing with Jasmine now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.