I can't get Angular mocks or angular itself to be recognized in an sbt-web / sbt-mocha project.
I was writing a sample based on the sbt-web play http://typesafe.com/activator/template/play-2.3-highlights highlights sample. I killed the other plugins but left the sbt-mocha one.
I declared the dependencies in libraryDependencies:
libraryDependencies ++= Seq(
"org.webjars" % "jquery" % "2.1.0-2",
"org.webjars" % "angularjs" % "1.3.0-beta.18",
"org.webjars" % "angular-ui-router" % "0.2.10-1",
"org.webjars" % "squirejs" % "0.1.0" % "test",
"org.webjars" % "chai" % "1.9.1" % "test"
)
I then wrote an angular app with a constant and dropped it in assets/javascripts as app.js:
angular.module('myApp', [])
.constant('PI', Math.PI);
Next, I wrote a test:
(function() {
'use strict';
describe('angular spec', function() {
beforeEach(module('myApp'));
it('should have an app with PI', inject(function(PI) {
expect(PI).to.be.defined();
}));
});
}());
I then fired up sbt mochaOnly and got:
[error] TypeError: module is not a function, it is object.
Now, I've tried using angular.mocks.module as well and it gives me an error that Angular doesn't exist.
I also added the same library to the test path, thinking maybe the test path was isolated from the main one, (silly idea) but that didn't help. I then tried following http://www.scala-js.org/doc/sbt/depending.html to include only the mocks js file like this:
"org.webjars" % "angularjs" % "1.3.0-beta.18" / "angular-mocks.js" % "test",
But it gave me an error around the "/" and didn't recognize it, so strike three...
I've done this dozens and dozens of times with gulp, grunt, even maven with the maven-jasmine-plugin but now I'm in sbt-web world, and it uses mocha, and there isn't any documentation to go on. I'm also new to Scala and would like to try to get something going, so apologies if I don't get it yet... Very possible!
I just want to bootstrap the angular mocks library with the module function, and then inject an angular asset like PI with inject.
I have a GitHub repo with this code in it... it is : https://github.com/krimple/sbt-web-project-with-angular/
Anyone want to hack on this with me? I'd love to figure it out and do a pull request for the play seed project for angular so that we actually have some mocha tests. Even better would be a jasmine sbt plugin but I think we're going to have to focus on mocha first.
You lack a dependency:
See if that's the issue.