Testing a Service

John Lindquist
InstructorJohn Lindquist

Share this video with your friends

Send Tweet

Using Jasmine, this lesson will look at testing an AngularJS service.

Bernardo
Bernardo
~ 7 years ago

Hi there. Really appreciate these videos! Up until now though, I don't think you've explained what we'd use a service for. It looks similar to factories and providers, but I'm not quite sure what canonical/happy-path use case they solve.

Paul
Paul
~ 7 years ago

Hi Bernardo. Use a service when you want just one of that kind of thing throughout your application. Authentication is a good example of a service...there's only going to be one user logged into the browser that is running an AngularJS application.

A factory, though, can have multiple instances created. Watch the videos about models and you can see some of the examples of how data does and doesn't get shared for services, factories, providers, controllers, etc.