I am testing my directive statement. It has templateUrlof:
/directives/Statement/statement.directive.html
The structure of my application file:
- tango
- client
- directives
- Statement
- statement.directive.html
- server
- test
I use Node + Express on the backend and app.use(express.static('client'));. So, the server will see the request /directives/Statement/statement.directive.htmland find it in the folder client.
I didn’t show static files before and had:
templateUrl: /client/directives/Statement/statement.directive.html
At this point, my tests worked fine. However, now that I am serving things under clientstatically and updated templateUrlaccordingly, my tests fail. This is the error message I get:
Error: Unexpected request: GET /directives/Statement/statement.directive.html
No more request expected
at $httpBackend (/Users/azerner/code/tango/test/lib/angular-mocks.js:1211:9)
at sendReq (/Users/azerner/code/tango/lib/angular.js:10335:9)
at serverRequest (/Users/azerner/code/tango/lib/angular.js:10047:16)
at processQueue (/Users/azerner/code/tango/lib/angular.js:14569:28)
at /Users/azerner/code/tango/lib/angular.js:14585:27
at Scope.$eval (/Users/azerner/code/tango/lib/angular.js:15848:28)
at Scope.$digest (/Users/azerner/code/tango/lib/angular.js:15659:31)
at Object.<anonymous> (/Users/azerner/code/tango/test/unit/directives/statement.directive.js:18:11)
at Object.invoke (/Users/azerner/code/tango/lib/angular.js:4452:17)
at Object.workFn (/Users/azerner/code/tango/test/lib/angular-mocks.js:2420:20)
Error: Declaration Location
at window.inject.angular.mock.inject (/Users/azerner/code/tango/test/lib/angular-mocks.js:2391:25)
at Suite.<anonymous> (/Users/azerner/code/tango/test/unit/directives/statement.directive.js:7:14)
at /Users/azerner/code/tango/test/unit/directives/statement.directive.js:1:1
TypeError: Cannot read property 'vm' of undefined
at Object.<anonymous> (/Users/azerner/code/tango/test/unit/directives/statement.directive.js:22:22)
TypeError: Cannot read property 'statement' of undefined
at Object.<anonymous> (/Users/azerner/code/tango/test/unit/directives/statement.directive.js:27:14)
I am using karma-ng-html2js-preprocessor . In karma.conf.jsI have:
files: [
'lib/jquery.js',
'lib/angular.js',
'lib/angular-ui-router.min.js',
'test/lib/angular-mocks.js',
'client/**/*.html',
'client/**/*.js',
'test/unit/**/*.js'
],
ngHtml2JsPreprocessor: {
moduleName: 'templates',
cacheIdFromPath: function(filepath) {
console.log(filepath);
return filepath;
},
stripPrefix: 'client'
},
He logs out of the system:
client/directives/Statement/statement.directive.html
client/templates/login.html
client/templates/signup.html
client/templates/home.html
client/templates/tango.html
And I remove the prefix client. Therefore, I think he should set the key
/directives/Statement/statement.directive.html
$templateCache, , ,
GET /directives/Statement/statement.directive.html
"" (?) $templateCache, .
, ?