Closed vance closed 10 years ago
Is your actual module MyLittleApp
already included before this file?
Example:
angular.module('MyLittleApp', ['ui.router']).config(...)
Of course there will be an error if Angular tries to reference a module that hasn't been declared yet...
Yes, of course the application is there. I can include the application module in my tests and they work fine.
I'm not sure what to tell you without a test case. Hundreds of people have been using this in both testing, development & production successfully, so why Karma is complaining that the module is not available is probably a Karma issue. (That error doesn't sound like an Angular error).
Here's what seems promising via Google:
http://stackoverflow.com/questions/19412109/angular-jasmine-test-not-finding-modules
I can open this up again once there's an example to work off of...
My tests work absolutely fine in both grunt-contrib-jasmine and karma. The tests can load the application module and, for instance, my NavController. It can run tests against it.
Its as soon as I include the app.template.js in my karma config, the application is undefined error is raised (from that file). Do I need to defer something? I've tried wrapping in IIFE wrappers even.
The same error is raised in both grunt-karma and in grunt-contrib-jasmine.
@vance I've had my own set of issues before with multiple modules & Karma (namely ui.bootstrap
, which is common in my stuff). Because Karma's such a ... interesting piece of architecture (I'm being polite here), can you take the Gruntfile.js, karma.conf.js, a core module, and show an example on how to reproduce this? Otherwise I'm flying blind here... =/
It would take a bit of time to clean out the project of business-specific doo-dads. But it could be done.
Thanks for your patience. I've created a stripped-down test project. I included all the node modules so you can just pull-n-go.
Run grunt karma:go or grunt runtJasmine. In this project it is possible to run the tests standalone without template.js... you can toggle this in the karma config by setting {pattern:'src/main/app/templates.js', included: true}, to false
Just realized i pushed a broken version (from my cleanup). Gimme a sec.
ok. I fixed the typo. It runs regardless, just wanted to make sure we are clear that's not the issue.
Any luck reproducing the problem of not finding the application module?
The template js file produces:
angular.module('MyLittleApp').run(['$templateCache', function($templateCache) { 'use strict';
$templateCache.put('src/main/app/components/nav/navigation.html',
but when Karma runs it, it says "Module 'MyLittleApp' is not available!" Without including this file tests work normally.