Learning BackboneJS Testing
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.
52 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Learning BackboneJS Testing to your Wishlist.

Add to Wishlist

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.
52 students enrolled
Created by Packt Publishing
Last updated 8/2015
Current price: $10 Original price: $75 Discount: 87% off
5 hours left at this price!
30-Day Money-Back Guarantee
  • 2 hours on-demand video
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
What Will I Learn?
  • 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
View Curriculum
  • Having knowledge of the node package management ecosystem will be beneficial, although not compulsory.

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.

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.
Students Who Viewed This Course Also Viewed
Curriculum For This Course
31 Lectures
Getting Started with Testing
4 Lectures 14:03

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.

The Course Overview

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

Testing and Why It’s Used

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

Understanding TDD versus BDD

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.

Investigating Our Toolshed
Understanding Jasmine
5 Lectures 14:23

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.

Preview 02:40

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

Making Our Way Through the Syntax

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

Writing a Simple Test

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

Hands-on Challenge – Adding to Our getNthElement Function

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.

Using BackboneJs in Jasmine Tests
Testing Models
5 Lectures 13:51

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

Preview 02:08

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.

Testing Instantiation and Defaults

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

Taking Care of Dietary Restrictions

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.

Introducing Fixtures

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

Hands-on Challenge – Refactoring to Use Fixtures
Automating the Process
4 Lectures 10:30

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

Preview 02:11

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

Installing Karma

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

Running Karma in Browsers

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.

Making Our Tests Work with Karma
Depending on AJAX
4 Lectures 15:36

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

Preview 03:17

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.

Hands-on Challenge – Getting All the Variations

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.

Mocking AJAX with SinonJs

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

Setting Up a Mock Backend Server
Testing Views
5 Lectures 24:37

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

Preview 02:54

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.

Templating and DOM Expectations

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.

Rendering Our View

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

Taking Notes

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.

Hands-on Challenge – Adding Recipes
Testing Routers
4 Lectures 15:44

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.

Preview 02:04

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.

Introducing Spies

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

Writing Our First Router Test

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

Hands-on Challenge – Routing Recipe Variations
About the Instructor
Packt Publishing
3.9 Average rating
8,175 Reviews
58,715 Students
686 Courses
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.