Skip to content

Instantly share code, notes, and snippets.

@karlwestin
Created July 23, 2014 11:13
Show Gist options
  • Save karlwestin/7506ec6c234ef32679c4 to your computer and use it in GitHub Desktop.
Save karlwestin/7506ec6c234ef32679c4 to your computer and use it in GitHub Desktop.
angular testing pt 2
/*
So it turns out angular writers are just half-familiar with jasmine etc practices
angular-mocks actually supports doing this:
*/
// Load the myApp module, which contains the directive
beforeEach(module('myApp'));
// Store references to $rootScope and $compile
// so they are available to all tests in this describe block
beforeEach(inject(function(_$compile_, _$rootScope_){
// The injector unwraps the underscores (_) from around the parameter names when matching
this.$compile = _$compile_;
this.$rootScope = _$rootScope_;
}));
it("should test compiler", function() {
// Compile service now available on 'this' scope (one scope per test)
// just like we wanna do with jasmine testing :)
this.$compile
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment