Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have multiple run blocks in angular and grunt?

I am setting up $httpBackend to stub out fake API routes while our API developers are working on them. The problem is I have to put all my $httpBackend definitions inside my run block. As a result, my run block will get quite large. I would like to know if there is a way to separate these out into different files, possibly using multiple run blocks, or even some grunt task to compact them all into a single run file.

like image 732
LordZardeck Avatar asked Apr 08 '15 15:04

LordZardeck


1 Answers

You can actually create multiple run blocks in angular. Simply separate each run blocks into different files.

DEMO

A contrive example would look like this:

app.js

angular.module('app', ['ngMockE2E']);

mock.users.js

angular.module('app')
  .run(function($httpBackend) {
    // implement user api mock
  });

mock.projects.js

angular.module('app')
  .run(function($httpBackend) {
     // implement project api mock
  });
like image 200
ryeballar Avatar answered Oct 19 '22 21:10

ryeballar