Skip to content

Instantly share code, notes, and snippets.

@alexanderfrankel
Last active December 28, 2015 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexanderfrankel/0a7d33349b564b5f179e to your computer and use it in GitHub Desktop.
Save alexanderfrankel/0a7d33349b564b5f179e to your computer and use it in GitHub Desktop.
testing-in-karma-dot-only.js
describe.only('MyController', function() {
// define some variables
var scope, httpBackend, myController;
// load in our app
beforeEach(module('MyApp'));
// code to execute before each of our tests
beforeEach(inject(function($rootScope, $httpBackend, $controller) {
httpBackend = $httpBackend;
scope = $rootScope.$new();
myController = $controller('MyController', {$scope: scope});
// simulates a GET request to our server
httpBackend.when('GET', '/students')
.respond({students: [{name: "alex", grade: "third"},
{name: "tom", grade: "second"},
{name: "silvio", grade: "first"}
]});
httpBackend.flush();
}));
...
)};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment