TypeError: 'undefined' is not a constructor (evaluating 'new JdRes())
angularjs, jasmine, javascript
Solution
Based on the information you've provided, the only conclusion I can make is that `jasmine.createSpy('JdRes')` returns `undefined`.
That means that either `jasmine.createSpy` doesn't have a `return` statement, or it tries to return something that has a value of `undefined`. You should check if the function does indeed have a `return` statement, and if it does, its returned value is not `undefined`. There's nothing further I can tell you.
Problem
I am writing jasmine test spec for an angular controller. Here, I get the error `TypeError: 'undefined' is not a constructor (evaluating 'new JdRes())` - though I've defined it as ``` JdRes = jasmine.createSpy('JdRes'); ``` The code segment in the controller is as follows ``` function (myService, $scope, $attrs, $q, $parse) { 'use strict'; var JdRes, resource; JdRes = myService('JdRes'); resource = new JdRes(); } ```