I create a project with :
mvn archetype:generate -DarchetypeGroupId=com.github.searls -DarchetypeArtifactId=jasmine-archetype -DarchetypeVersion=1.3.1.5 -DgroupId=com.acme -DartifactId=my-jasmine-project -Dversion=0.0.1-SNAPSHOT
First I test with mvn jasmine:test the test are run normally.
note : I use maven 3.2.1
In the "target" directory I add a folder "phantomjs-1.9.7-windows" where I put "phantomjs.exe"
I modifie my original pom.xml to add
...
<configuration>
<srcDirectoryName>${project.artifactId}/src/main/javascript</srcDirectoryName>
<webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
<webDriverCapabilities>
<capability>
<name>phantomjs.binary.path</name>
<value>${project.build.directory}/phantomjs-1.9.7-${os.phantomJS}/${run.phantomJS}</value>
</capability>
</webDriverCapabilities>
<preloadSources>
<source>${project.basedir}/src/main/javascript/libs/jquery-1.9.1.js</source>
<source>${project.basedir}/src/main/javascript/libs/angular.js</source>
<source>${project.basedir}/src/main/javascript/libs/angular-ui-router.js</source>
<source>${project.basedir}/src/main/javascript/libs/angular-resource.js</source>
</preloadSources>
</configuration>
...
I create a folder "libs" under "src/main/javascript" and I put in it : - jquery-1.9.1.js - angular.js - angular-ui-router.js - angular-resource.js
note : angular is in verion 1.2.23
After that I create an other folder "app" under "src/main/javascript" and I put in it : "app.module.js"
(function() {
'use strict';
angular.module('app', [
'app.Security.modules'
]);
})();
Under "src/main/javascript/app" I create a folder "security" and I put in it : "security.module.js"
(function() {
'use strict';
angular.module('app.Security.modules', []);
})();
and "cha_directive.js"
angular.module('app.Security.modules').directive('inputOld', InputAccessKeyManagement);
function InputAccessKeyManagement () {}
If I test with mvn jasmine:test I obtain an error :
[ERROR - 2015-02-26T08:12:49.751Z] Session [40eacc20-bd8f-11e4-a736-9934c466a5ff] - page.onError - stack:
(anonymous function) (http://localhost:51170/jasmine-project/src/main/javascript/libs/angular.js:1679)
ensure (http://localhost:51170/jasmine-project/src/main/javascript/libs/angular.js:1601)
module (http://localhost:51170/jasmine-project/src/main/javascript/libs/angular.js:1892)
(anonymous function) (http://localhost:51170/jasmine-project/src/main/javascript/app/security/cha_directive.js:1)
[WARNING] JavaScript Console Errors:
* Error: [$injector:nomod] Module 'app.Security.modules' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.2.23/$injector/nomod?p0=app.Security.modules
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.163s
[INFO] Finished at: Thu Feb 26 09:12:49 CET 2015
[INFO] Final Memory: 12M/210M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.searls:jasmine-maven-plugin:1.3.1.5:test (default-cli) on project jasmine-project: The jasmine-maven-plugin encountered an exception:
[ERROR] java.lang.RuntimeException: java.lang.RuntimeException: There were javascript console errors.
[ERROR] at com.github.searls.jasmine.runner.SpecRunnerExecutor.execute(SpecRunnerExecutor.java:46)
[ERROR] at com.github.searls.jasmine.mojo.TestMojo.executeSpecs(TestMojo.java:86)
If I just rename "cha_directive.js" in "toto_directive.js" (with the same source code) and I run mvn jasmine:test again the test are run normally.
If I use "cha_directive.js" name file and run mvn jasmine:bdd. After that I run the url http://localhost:8234 in FF the tests are run normally.
The only thing (if I edit the HTML code of "Jasmine Spec Runner" with fireBug) is that I can see this tag :
<head jmp_jserror="Error: [$injector:nomod] Module 'app.Security.modules' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.2.23/$injector/nomod?p0=app.Security.modules">
If I look in class SpecRunnerExecutor.java in "checkForConsoleErrors" there is a test :
WebElement head = driver.findElement(By.tagName("head"));
if (head != null) {
String jserrors = head.getAttribute("jmp_jserror");
if (StringUtils.isNotBlank(jserrors)) {
throw new RuntimeException("There were javascript console errors.");
}
}
note : other file name crash the tests : input_directive.js, accessKey_directive.js, ...
It is a problem of import script order.
I declare
(function() {
'use strict';
angular.module('app.Security.modules', []);
})();
in a file named "security.module.js"
and I try to use my declaration
angular.module('app.Security.modules')
.directive('inputOld', InputAccessKeyManagement);
function InputAccessKeyManagement () {}
in a file named "cha_directive.js"
If you don't specify a custom import script order the default one is alphabetical then "cha_directive.js" is before "security.module.js".
I solved the problem using a "customRunnerTemplate".
But maybe there was another way to do "prettier" ?