Gulp-jasmine gives TypeError
I started trying to learn javascript unit testing with a test project. The project has gulpfile.js at its root, which contains this: 'use strict';
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')({
config: {
'dependencies': {
'gulp-jasmine': '*'
}
},
camelize: true
});
gulp.task('jstest', function() {
return gulp.src(['js_unit_tests/*'])
.pipe(plugins.jasmine({ verbose: true, showStackTrace: true }));
});
The only file in the js_unit_tests directory is grid-tests.js, and it looks like this:
///<reference path="../Scripts/jasmine/jasmine.js" />
///<reference path="../Scripts/angular.js" />
///<reference path="../Scripts/angular-mocks.js" />
///<reference path="../Scripts/underscore.js" />
///<reference path="../app.js" />
///<reference path="../Scripts/Components/Grid/grid.js" />
describe('GridController Test', function () {
beforeEach(module('app'));
describe('GridCtrl', function () {
var scope,
controller,
timeout;
beforeEach(inject(function ($rootScope, $controller, $timeout) {
scope = $rootScope.$new();
controller = $controller;
timeout = $timeout;
}));
it('should initialize vm values without scope isolate properties being provided', function () {
var cont = controller('GridCtrl', { $scope: scope, $timeout: timeout });
expect(scope.actions).toBeUndefined();
expect(scope.data).toBeUndefined();
expect(scope.settings).toBeUndefined();
expect(cont.actions instanceof Array).toBeTruthy();
expect(typeof (cont.data)).toBe('object');
expect(typeof (cont.settings)).toBe('object');
expect(cont.gridActions instanceof Array).toBeTruthy();
expect(cont.columnDefinitions instanceof Array).toBeTruthy();
expect(cont.rows instanceof Array).toBeTruthy();
expect(cont.selectedColumnDefinitionId).toBe('');
expect(cont.selectedRowId).toBe(0);
expect(typeof (cont.onclick)).toBe('function');
expect(typeof (cont.onblur)).toBe('function');
expect(cont.sortedColumn).toBe('');
expect(cont.sortDirection).toBe('none');
expect(typeof (cont.sort)).toBe('function');
});
});
});
All tests are run and submitted using resharper. Doing the above gulp task though gives me this:
<dir>\Experiment\AngularUIComponents\AngularUIComponents>gulp
jstest
[16:40:43] Using gulpfile ~\Desktop\a\Experiment\AngularUIComponents\AngularUICo
mponents\gulpfile.js
[16:40:43] Starting 'jstest'...
Running 1 specs.
GridController Test
encountered a declaration exception: failed
Failures:
1) GridController Test encountered a declaration exception
1.1) TypeError: object is not a function
1 spec, 1 failure
Finished in 0.008 seconds
[16:40:43] 'jstest' errored after 62 ms
[16:40:43] Error in plugin 'gulp-jasmine'
Message:
Tests failed
I cannot figure out what I have configured wrong. Any help would be greatly appreciated.
+3
source to share
No one has answered this question yet
Check out similar questions: