I have the following gulpfile.js
:
var gulp = require('gulp'),
jasmine = require('gulp-jasmine');
gulp.task('default', function () {
return gulp
.src('spec/test.js')
.pipe(jasmine());
});
The code inside spec/test.js
uses a global angular
variable, however, and throws an error about it being undefined when I run gulp task default
. Let's say angular
is defined in file spec/lib.js
, in global scope.
How do I tell jasmine()
what dependencies it needs to load first into the global scope before running the describe()
s inside test.js
? In other words, how do I tell jasmine()
to load spec/lib.js
first, before it runs the tests?
Have you tried KARMA?
KARMA LINK
If you use karma, jasmine, and gulp, which I do, you can configure your testing like this
NOTE: If you can't get it to work right off let me know and we'll TS it. Perhaps I missed something. My test files are named something_test.js, not something_spec.js. I changed the code to create _spec.js. Also, you have to make sure you have included all the files you need to run Angular. I provided some examples in my karma.config.js. I run Angular as well.
The preprocessor (ng-html2js) compiles the angular templates for directives. You must install it in your package.json.