O'Reilly logo

AngularJS Directives by Alex Vanston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mocking data

Often when we're testing different pieces of an application, we need to validate how that piece responds to specific data input. We don't however, want to be dependent on an external source for that data; there's nothing worse than spending several hours trying to debug your failing tests only to realize that your third-party data is corrupt. Because of this, whenever possible we want to use mocked sample data for our tests so that we can be sure of the validity, or invalidity if we're negative testing, of the input our directive is receiving.

Note

As a side note, whenever possible your directive should not be responsible for actually retrieving the information. Angular provides services as a more modular way of handling information, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required