Chooce video playback speed
speed:1

Testing a Controller

InstructorJohn Lindquist

Share this video with your friends

Send Tweet

AngularJS provides helpers for convenient testing of your application. In this lesson you will learn how to test a basic controller with Jasmine and Angular.

This lesson is a Community Resource

A Community Resource means that it’s free to access for all. The instructor of this lesson requested it to be open to the public.

John Lindquist: To test a controller, we're going to start the same way we always start, with a beforeEach for our module, a beforeEach for the injection, and we'll inject in the controller provider. Then we can get the app control right here, which we'll get off of our module, and we will create our app controller.

From here, we'll split him, move it up, probably seen that happen a million times now, and we'll describe our app controller.

Basically, we're just going to say it should have a message of "Hello", and then we can expect our appCtrl.message to be "Hello". This should fail nicely for us, and we'll say this message is "Hello", and it passes.

That's kind of the same setup as always, module, inject, use a controller provider, get the controller, and then start running some tests against it. We'll go into more controller tests soon.