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.
29 students enrolled
$19
$75
75% 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

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

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

What 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.

Curriculum

Section 1: Getting Started with Testing
02:42

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.

05:05

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

04:05

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

02:11

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
02:40

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.

02:48

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

04:40

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

01:33

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

02:42

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
02:08

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

02:39

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.

04:04

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

02:48

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.

02:12

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
02:11

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

02:55

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

02:18

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

03:06

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
03:17

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

04:31

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.

04:23

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.

03:25

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
02:54

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

05:34

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.

04:06

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.

07:29

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

04:34

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
02:04

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.

04:01

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.

04:43

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

04:56

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

Over the past ten years Packt Publishing has developed an extensive catalogue of over 2000 books, e-books and video courses aimed at keeping IT professionals ahead of the technology curve. From new takes on established technologies through to the latest guides on emerging platforms, topics and trends – Packt's focus has always been on giving our customers the working knowledge they need to get the job done. Our Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.

Ready to start learning?
Take This Course