We're trying to get our angular/jasmine tests to run with Maven using
the jasmine-maven-plugin
(https://github.com/searls/jasmine-maven-plugin). I think we are
almost there - the trick is to use <preloadSources> to load
angular/angular-mocks in correct order before the tests. This setup
generates good test runners which executes flawless in the browser.
But when I run the tests from the command line and the tests executes
in the maven plugin (which uses HtmlUnit) i get an error like this:
1.) FooCntl it should add good from-date defaults <<< FAILURE!
* TypeError: Cannot read property "1" from null in
file:/.../js-lib/angular-0.9.15.patched.js (line 2367)
Which corresponds to the 'forEach'-line in this method:
var FN_ARGS = /^function\s*[^\(]*\(([^\)]*)\)/;
var FN_ARG_SPLIT = /,/;
var FN_ARG = /^\s*(((\$?).+?)(_?))\s*$/;
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
function injectionArgs(fn) {
assertArgFn(fn);
if (!fn.$inject) {
var args = fn.$inject = [];
var fnText = fn.toString().replace(STRIP_COMMENTS, '');
var argDecl = fnText.match(FN_ARGS);
forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg){
arg.replace(FN_ARG, function(all, name, injectName, $, _){
assertArg(args, name, 'after non-injectable arg');
if ($ || _)
args.push(injectName);
else
args = null; // once we reach an argument which is not
injectable then ignore
});
});
}
return fn.$inject;
}
Looks to me like HtmlUnit does not behaive as expected by angular
regarding fn.toString()? Any suggestions how to fix this are welcome.
(I can work around this by instead of using "angular.scope();
scope.$new(FooCntl);" to setup my controller use "new FooCntl()", but
that gets ugly very fast when you need to inject dependencies.)
Thanks!
/Mårten
Problem was that FN_ARGS did not match multiline string.
fnArgs looked like this:
"
function () {
return arguments.length ? fn.apply(self,
curryArgs.concat(slice.call(arguments, 0, arguments.length))) :
fn.apply(self, curryArgs);
}
"
Note the newline in the beginning of the line. Adding the multiline
modifier to FN_ARGS solved the issue for me:
- var FN_ARGS = /^function\s*[^\(]*\(([^\)]*)\)/;
+ var FN_ARGS = /^function\s*[^\(]*\(([^\)]*)\)/m;
/Mårten
2011/4/26 Mårten Dolk <marte...@gmail.com>:
Sent from my iPad
> --
> You received this message because you are subscribed to the Google Groups "Angular" group.
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to angular+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/angular?hl=en.
>
/mårten
2011/4/26 Miško Hevery <misko....@gmail.com>:
angular.service('$exceptionHandler', function(e) {
return function(e) {throw e;};
}, {$inject:[]});
I will create a demo project using Java server-side, Angular in
browser, and Maven to build and execute tests and put it on github. I
hope I will have time to do this Monday and create a pull request with
my issues.
/Mårten
2011/4/27 Mårten Dolk <marte...@gmail.com>:
Run into a new problem when migrating to angular-0.9.17. This time in
angular-mocks.js. The mock implementation of $exceptionHandler needs
the {$inject:[]} argument to angular.service or my jasmine spec runner
will throw an Error "Unknown provider for 'e'." This is the fixed
version:
angular.service('$exceptionHandler', function(e) {
return function(e) {throw e;};
}, {$inject:[]});
I will create a demo project using Java server-side, Angular in
browser, and Maven to build and execute tests and put it on github. I
hope I will have time to do this Monday and create a pull request with
my issues.
You received this message because you are subscribed to the Google Groups "angular" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
Run into a new problem when migrating to angular-0.9.17. This time in
angular-mocks.js. The mock implementation of $exceptionHandler needs
the {$inject:[]} argument to angular.service or my jasmine spec runner
will throw an Error "Unknown provider for 'e'." This is the fixed
version:
angular.service('$exceptionHandler', function(e) {
return function(e) {throw e;};
}, {$inject:[]});
angular.service('$exceptionHandler', function() {return function(e) {throw e;};});
I will create a demo project using Java server-side, Angular in
browser, and Maven to build and execute tests and put it on github. I
hope I will have time to do this Monday and create a pull request with
my issues.
I have my example project using Maven to build an Angular web-app with
Java backend up on github here:
https://github.com/mdolk/angular-java-server-midi
I also created a pull request with what I needed to change in Angular
to make this work, here:
https://github.com/angular/angular.js/pull/453
/Mårten
2011/7/4 jmilkiewicz <jmilk...@gmail.com>:
We are using it because it can report test results in the junit xml
format which is a defacto standard for CI servers in Java, hence we
get good integration with Hudson/Jenkins.
/mårten
2011/7/22 Igor Minar <iim...@gmail.com>:
http://ci.angularjs.org/job/angular.js-angular-master/
/i
btw JSTestDriver (jstd) is primarily designed to run unit tests. we
however managed to get our e2e test runner to work on jstd as well.
/i
-- dan
Sent from my iPhone
/i