Data mocking in angular E2E testing

We needed to create a suite of e2e tests for our web app, preferably without having to hit the database for obvious reasons.
So basically I wanted to have a solution that satisfies these requirements:

  • Allows easy switch between real and test data, for example by specifying a URL parameter.
  • Allow specifying a mock data source, and a way to manipulate that mock data after it was loaded from the source.

Angular has a fake $httpBackend implementation designed specifically for providing a mock data response when you’re using $http service. Continue reading “Data mocking in angular E2E testing”