4

statementディレクティブをテストしています。次のものがtemplateUrlあります。

/directives/Statement/statement.directive.html

私のアプリのファイル構造:

- tango
  - client
    - directives
      - Statement
        - statement.directive.html
  - server
  - test

バックエンドで Node + Express を使用しており、app.use(express.static('client'));. したがって、サーバーはリクエストを見て、フォルダー/directives/Statement/statement.directive.htmlの下でそれを見つけます。client

以前は、静的ファイルを提供していませんでした。

templateUrl: /client/directives/Statement/statement.directive.html

この時点で、私のテストは問題なく実行されていました。ただし、client静的にサービスを提供し、それに応じて更新したためtemplateUrl、テストは失敗しています。これは私が得ているエラーメッセージです:

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)

私はkarma-ng-html2js-preprocessorを使用しています。karma.conf.js私は持っています:

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'
},

ログアウトしています:

client/directives/Statement/statement.directive.html
client/templates/login.html
client/templates/signup.html
client/templates/home.html
client/templates/tango.html

そして、clientプレフィックスを削除しています。だから私はそれがのキーを設定する必要があると思います

/directives/Statement/statement.directive.html

$templateCacheの 、したがって、

GET /directives/Statement/statement.directive.html

リクエストは「傍受」(?) される$templateCache必要があり、これは問題になりません。


問題は何ですか?どうすれば修正できますか?

4

0 に答える 0