Can you please explain how this line works:
beforeEach(module('phonecatApp'));
beforeEach() expects a callback function to call before each test. module() returns an angular.Module object.
What does beforeEach() do with an object?
If you look in the source of angular.mock.module
you can see it either returns a function, or the result of a function, depending on whether a spec is running:
window.module = angular.mock.module = function() {
var moduleFns = Array.prototype.slice.call(arguments, 0);
return isSpecRunning() ? workFn() : workFn;
/////////////////////
function workFn() {
...
When beforeEach
is called, I suspect this is treated as not being during a spec, so the function returns a callback that runs when the test runner later calls the callbacks registered with beforeEach
.
Also I don't see documented, or in the source, that it actually returns a module object. It apparently registers a module with the dependency injection system.