Learning BackboneJS Testing

An interactive guide to perform automated testing on BackboneJs applications with the help of a real-world example
5.0 (2 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
34 students enrolled
80% off
Take This Course
  • Lectures 31
  • Length 2 hours
  • Skill Level Beginner Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

About This Course

Published 8/2015 English

Course Description

The dynamic nature and flexibility of JavaScript and BackboneJs includes many ways of expressing ideas. Such liberty gives way to certain risks that aren't as prominent in strongly typed languages and highly opinionated libraries and frameworks. Learning how to mitigate these risks is a crucial step to writing smarter software, and smarter software makes for happy developers!

Learning BackboneJs Testing will bootstrap you into a world of JavaScript testing and provide you with fundamental experience in writing tests. By understanding and becoming comfortable in testing BackboneJs applications, you can increase your productivity, code quality, and design skills.

At the beginning, we'll discuss different testing philosophies and go over some testing basics. After establishing a motivation for and philosophy of testing, we're going to dive right into how we express our tests in Jasmine's BDD syntax. We'll also hone in on how to deal with the DOM and AJAX in our tests.

Once you learn some syntax and apply it to plain JavaScript and BackboneJs code, we're going to run into the problem of manual testing practices. We'll discuss and incorporate a tool that will automate our tests and make testing considerably more streamlined using Karma. From there, you'll learn to apply testing techniques and tools such as fixtures and spies. This course will jump-start your automated testing experience and you'll be writing robust tests for everyday objects!

About The Author

Jonathan Freeman is a jazz saxophone player and home cook, and loves to solve problems with code. He wrote his first production application 12 years ago and has been working with BackboneJs in production for the past 3 years. From writing articles for InfoWorld to presenting at conferences and user groups, he loves to teach and jumps at the opportunity to facilitate and observe learning. He's currently interested in complex event processing with rules engines, constraint-based optimization problems, and the fast-moving DevOps ecosystem. He gets to play with all of these technologies and more while at his day job at Spantree Technology Group, a Chicago-based consulting firm. You can find him on twitter at @freethejazz.

What are the requirements?

  • Having knowledge of the node package management ecosystem will be beneficial, although not compulsory.

What am I going to get from this course?

  • Learn to set up an optimized automated testing environment to reduce manual testing woes and lower the barrier to entry
  • Use and customize a breadth of common testing tools to prepare you for real-world scenarios
  • Implement the testing techniques on a BackboneJs application to build experience and increase comfort while testing

Who is the target audience?

  • If you have a solid understanding of JavaScript, experience writing frontend code using Backbone.js and want to start with testing your app, this course is perfect for you.

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.


Section 1: Getting Started with Testing

The viewer may not know what's in store for them in this course yet. We'll tell you what the scope of the course is, what the goals are, and how we'll go about it.


Testing adds overhead and time to a development process. We want to explain the benefits of testing and describe unit testing and functional testing.


Describe the nuances between TDD and BDD. Prevent confusion of these very similar concepts.


Many tools help in automated testing and it's hard to decide where to start. We'll narrow down the list and describe the necessary programs.

Section 2: Understanding Jasmine

You may not have experience with Jasmine, and may not even have it on your computer. We'll download the library and go through an overview of the directory structure.


Jasmine provides a set of global functions, which we'll introduce and discuss here.


Viewers will get their hands dirty by writing a test using Jasmine style syntax.


We want to add a new feature to our function. The viewer is going to add it on their own in this challenge.


Our tests so far have been vanilla JavaScript, but the rest of the course will be focused on Backbone tests. We'll integrate the library here.

Section 3: Testing Models

Our section will rely on an understanding of what the recipe model should do. We'll introduce that understanding here.


We need to make sure we start our model testing on the right foot. This video will ensure its existence and that the defaults are configured properly.


We want to be able to check quickly for dietary restrictions. We'll test and implement those methods here.


Some of the setup code is redundant and provides more information than needed. Fixtures will help us cut down on that verbosity and make tests easier to grok.


A fixture is a new concept, and it can be very useful. This hands-on challenge will encourage you to practice using them.

Section 4: Automating the Process

Running automated tests manually is tedious and repetitive. Karma can serve as the automation we need.


We don't yet have the tool to run our tests. We'll install Karma.


We've configured Karma but haven't used it to run any tests yet, which we'll do in this video.


Our code has been fairly disorganized and is arranged in a way that requires us to use Jasmine. We'll refactor and run our tests with Karma.

Section 5: Depending on AJAX

We don't have a way to store recipes together. We'll create a recipe collection.


We want to be able to see a history of variations in a recipe. The user will write the test and method on their own.


Certain parts of our app depend on AJAX, which can be problematic in a testing environment. The solution is to use SinonJs to intercept AJAX requests and fake responses.


One-off server mocks clutter our code and hamper reusability. Storing our server responses in a single file will encourage cleanliness and maintainability.

Section 6: Testing Views

Testing views presents a new set of challenges related to dependence on the DOM. We'll start writing tests and run into these issues.


The unique requirements of testing views merit the use of a new library. jasmine-jquery will help us test views in a more efficient and straightforward way.


We need to ensure that our view is rendering properly. With our tools used to effectively test the DOM in place, we're ready to go.


Our recipe app depends on the ability to add notes to a recipe variation. We'll add this functionality, testing with jasmine-jquery.


We can render existing recipes, but we have no way of adding new recipes. In this video, you'll be challenged to write the add recipe view.

Section 7: Testing Routers

Routers are often left to functional testing, but it can be worth unit testing them. We'll discuss when and where to unit test routers.


We need to verify that our route handlers are getting called with the right parameters. We'll discuss spies, which help us track and test calls to functions.


Our first route will be accessing a recipe by ID. In this video, we'll test drive the addition of this route.


In this video, I'll challenge the viewer to use spies on their own by test driving a route on their own.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Packt Publishing, Tech Knowledge in Motion

Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.

With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.

From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.

Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.

Ready to start learning?
Take This Course