I am currently working on writing a simple test case for the driver script using IIFE(Immediately invoked function expression). Here is my driver script.
driver.js
(function() {
"use strict";
var app = angular
.module("myApp", [
"ui.bootstrap",
"ui.sortable"
]);
}());
Here is my spec driver.spec.js
describe("application configuration tool driver", function() {
it("should create an angular module named myTest", function() {
expect(app).toEqual(angular.module("myApp"));
});
});
When I run my spec using IIFE. I am getting a ReferenceError: app is not defined.
If I run the driver script without IIFE:
var app = angular
.module("myApp", [
"ui.bootstrap",
"ui.sortable"
]);
My spec passes. Any thoughts on passing the spec using IIFE?
appis local to IIFE, but the testexpect(app).toEqual(angular.module("myApp"));makes no sense to me.app?appfor creating custom directives and controllers.var appin combination withapp.controller ...,app.factory ...and unfortunately people aren't aware this is an anti-pattern.