2014-09-26 54 views
8

任何人都知道如何解決/刪除這非常惱人的警告?WARN [網絡服務器]:404:/views/nav/offline.html

Running "karma:unit" (karma) task 
INFO [karma]: Karma v0.12.23 server started at http://localhost:8080/ 
INFO [launcher]: Starting browser PhantomJS 
INFO [PhantomJS 1.9.7 (Windows 7)]: Connected on socket rrNTMtmcd322dIl7A9fa with id 95590782 
WARN [web-server]: 404: /views/nav/offline.html 
WARN [web-server]: 404: /views/scan/scan.qr.html 

karma.conf.js

// Karma configuration 
// http://karma-runner.github.io/0.12/config/configuration-file.html 
// Generated on 2014-08-26 using 
// generator-karma 0.8.3 

module.exports = function (config) { 
    'use strict'; 

    config.set({ 
     // enable/disable watching file and executing tests whenever any file changes 
     autoWatch: true, 

     // base path, that will be used to resolve files and exclude 
     basePath: '../', 

     // testing framework to use (jasmine/mocha/qunit/...) 
     frameworks: ['jasmine'], 

     // list of files/patterns to load in the browser 
     files: [ 
      'bower_components/angular/angular.js', 
      'bower_components/angular-mocks/angular-mocks.js', 
      'bower_components/angular-animate/angular-animate.js', 
      'bower_components/angular-cookies/angular-cookies.js', 
      'bower_components/angular-resource/angular-resource.js', 
      'bower_components/angular-route/angular-route.js', 
      'bower_components/angular-sanitize/angular-sanitize.js', 
      'bower_components/angular-touch/angular-touch.js', 
      'bower_components/angular-ui-router/release/angular-ui-router.js', 
      'bower_components/angular-local-storage/angular-local-storage.js', 
      'bower_components/ionic/release/js/ionic.js', 
      'bower_components/ionic/release/js/ionic-angular.js', 
      'app/scripts/**/*.js', 
      'test/spec/**/*.js' 

     ], 

     // list of files/patterns to exclude 
     exclude: [], 

     // web server port 
     port: 8080, 

     // Start these browsers, currently available: 
     // - Chrome 
     // - ChromeCanary 
     // - Firefox 
     // - Opera 
     // - Safari (only Mac) 
     // - PhantomJS 
     // - IE (only Windows) 
     browsers: [ 
      'PhantomJS' 
     ], 

     // Which plugins to enable 
     plugins: [ 
      'karma-phantomjs-launcher', 
      'karma-jasmine' 
     ], 

     // Continuous Integration mode 
     // if true, it capture browsers, run tests and exit 
     singleRun: false, 

     colors: true, 

     // level of logging 
     // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG 
     logLevel: config.LOG_INFO 

     // Uncomment the following lines if you are using grunt's server to run the tests 
     // proxies: { 
     // '/': 'http://localhost:9000/' 
     // }, 
     // URL root prevent conflicts with the site root 
     // urlRoot: '_karma_' 
    }); 
}; 

enter image description here

app.js

.config(function ($stateProvider, $urlRouterProvider) { 

    $stateProvider 

     // ACCOUNT 
     .state('account', { 
      abstract: true, 
      url: '/account', 
      templateUrl: 'index.html' 
     }) 
     .state('account.main', { 
      url: '', 
      templateUrl: 'views/account/account.main.html' 
     }) 
     . 
     . 
     . 

     // MENU 
     .state('menu', { 
      abstract: true, 
      url: '/menu', 
      templateUrl: 'views/nav/menu.html' 
     }) 
     .state('menu.main', { 
      url: '/main', 
      views: { 
       'menuContent': { 
        templateUrl: 'views/dash/dash.main.html' 
       } 
      } 
     }) 
     . 
     . 
     . 

     // OFFLINE MENU 
     .state('offline', { 
      abstract: true, 
      url: '/offline', 
      templateUrl: 'views/nav/offline.html' 
     }) 
     .state('offline.product', { 
      url: '/product', 
      views: { 
       'menuContent': { 
        templateUrl: 'views/product/product.list.html' 
       } 
      } 
     }) 
     .state('offline.qr', { 
      url: '/qr', 
      views: { 
       'menuContent': { 
        templateUrl: 'views/scan/scan.qr.html' 
       } 
      } 
     }) 
     .state('offline.cart', { 
      url: '/cart', 
      views: { 
       'menuContent': { 
        templateUrl: 'views/cart/cart.list.html' 
       } 
      } 
     }) 
    ; 

    $urlRouterProvider.otherwise('/account'); 

}) 

我也曾經嘗試這樣做相關的問題:
how to fix 404 warnings for images during karma unit testing
沒有運氣。

更多信息

我也曾嘗試以下:)

'app/scripts/**/*.js',    
'test/spec/**/*.js', 
{pattern: 'app/views/**', watched: false, included: false, served: true} 

3排除:
1)添加路徑HTML:

'app/scripts/**/*.js', 
'app/views/**/*.html', 
'test/spec/**/*.js' 

2)創建圖案html文件的路徑:

// list of files/patterns to exclude 
exclude: ['app/views/**'], 

但沒有任何工作,警告仍然存在。我假設這可能是一個錯誤?

編輯1

我只是做了乍得羅賓遜說,接下來的警告是關於失蹤index.html
因此,我所做的是:

proxies: { 
    '/views/': '/app/views/', 
    '/index.html': '/app/index.html' 
} 

但仍有警告:

Microsoft Windows [Version 6.1.7601] 
Copyright (c) 2009 Microsoft Corporation. All rights reserved. 

C:\Grabhut.MobileApp\Grabhut>grunt 
Running "newer:jshint" (newer) task 

Running "newer:jshint:all" (newer) task 
No newer files to process. 

Running "newer:jshint:test" (newer) task 
No newer files to process. 

Running "clean:server" (clean) task 
Cleaning .tmp...OK 

Running "concurrent:test" (concurrent) task 

Running "compass:dist" (compass) task 
directory .tmp/styles 
     write .tmp/styles/icomoon.css (0.007s) 
     write .tmp/styles/override.css (0.055s) 

Running "compass:server" (compass) task 

Done, without errors. 

Running "autoprefixer:dist" (autoprefixer) task 
File .tmp/styles/icomoon.css created. 

C:\Grabhut.MobileApp\Grabhut>grunt 
Running "newer:jshint" (newer) task 

Running "newer:jshint:all" (newer) task 
No newer files to process. 

Running "newer:jshint:test" (newer) task 
No newer files to process. 

Running "clean:server" (clean) task 
Cleaning .tmp...OK 

Running "concurrent:test" (concurrent) task 

Running "compass:dist" (compass) task 
directory .tmp/styles 
     write .tmp/styles/icomoon.css (0.007s) 
     write .tmp/styles/override.css (0.054s) 

Running "compass:server" (compass) task 

Done, without errors. 

Running "autoprefixer:dist" (autoprefixer) task 
File .tmp/styles/icomoon.css created. 
File .tmp/styles/override.css created. 

Running "connect:test" (connect) task 
Started connect web server on http://localhost:9001 

Running "karma:unit" (karma) task 

C:\Grabhut.MobileApp\Grabhut\test\karma.conf.js:73 

C:\Grabhut.MobileApp\Grabhut>grunt 
Running "newer:jshint" (newer) task 

Running "newer:jshint:all" (newer) task 
No newer files to process. 

Running "newer:jshint:test" (newer) task 
No newer files to process. 

Running "clean:server" (clean) task 
Cleaning .tmp...OK 

Running "concurrent:test" (concurrent) task 

Running "compass:dist" (compass) task 
directory .tmp/styles 
     write .tmp/styles/icomoon.css (0.007s) 
     write .tmp/styles/override.css (0.054s) 

Running "compass:server" (compass) task 

Done, without errors. 

Running "autoprefixer:dist" (autoprefixer) task 
File .tmp/styles/icomoon.css created. 

C:\Grabhut.MobileApp\Grabhut>grunt 
Running "newer:jshint" (newer) task 

Running "newer:jshint:all" (newer) task 
No newer files to process. 

Running "newer:jshint:test" (newer) task 
No newer files to process. 

Running "clean:server" (clean) task 
Cleaning .tmp...OK 

Running "concurrent:test" (concurrent) task 

Running "compass:dist" (compass) task 
directory .tmp/styles 
     write .tmp/styles/icomoon.css (0.007s) 
     write .tmp/styles/override.css (0.055s) 

Running "compass:server" (compass) task 

Done, without errors. 

Running "autoprefixer:dist" (autoprefixer) task 
File .tmp/styles/icomoon.css created. 
File .tmp/styles/override.css created. 

Running "connect:test" (connect) task 
Started connect web server on http://localhost:9001 

Running "karma:unit" (karma) task 
INFO [karma]: Karma v0.12.23 server started at http://localhost:8080/ 
INFO [launcher]: Starting browser PhantomJS 
INFO [PhantomJS 1.9.7 (Windows 7)]: Connected on socket PFqYQtg4gwm4psBKKJ5T with id 70053285 
PhantomJS 1.9.7 (Windows 7): Executed 0 of 0 ERROR (0.001 secs/0 secs) 
Warning: Task "karma:unit" failed. Use --force to continue. 

Aborted due to warnings. 


Execution Time (2014-09-29 02:06:16 UTC) 
concurrent:test  6.3s ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 78% 
autoprefixer:dist 97ms ■■ 1% 
connect:test  433ms ■■■■■■■■■ 5% 
karma:unit   1.2s ■■■■■■■■■■■■■■■■■■■■■■■ 15% 
Total 8.1s 


C:\Grabhut.MobileApp\Grabhut>  

這有什麼錯噶?

編輯2 Karma.conf.js

在底部看到卡拉馬配置更新:

// Karma configuration 
// http://karma-runner.github.io/0.12/config/configuration-file.html 
// Generated on 2014-08-26 using 
// generator-karma 0.8.3 

module.exports = function (config) { 
    'use strict'; 

    config.set({ 
     // enable/disable watching file and executing tests whenever any file changes 
     autoWatch: true, 

     // base path, that will be used to resolve files and exclude 
     basePath: '../', 

     // testing framework to use (jasmine/mocha/qunit/...) 
     frameworks: ['jasmine'], 

     // list of files/patterns to load in the browser 
     files: [ 
      'bower_components/angular/angular.js', 
      'bower_components/angular-mocks/angular-mocks.js', 
      'bower_components/angular-animate/angular-animate.js', 
      'bower_components/angular-cookies/angular-cookies.js', 
      'bower_components/angular-resource/angular-resource.js', 
      'bower_components/angular-route/angular-route.js', 
      'bower_components/angular-sanitize/angular-sanitize.js', 
      'bower_components/angular-touch/angular-touch.js', 
      'bower_components/angular-ui-router/release/angular-ui-router.js', 
      'bower_components/angular-local-storage/angular-local-storage.js', 
      'bower_components/ionic/release/js/ionic.js', 
      'bower_components/ionic/release/js/ionic-angular.js', 
      'app/scripts/**/*.js', 
      'test/spec/**/*.js' 

     ], 

     // list of files/patterns to exclude 
     exclude: [], 

     // web server port 
     port: 8080, 

     // Start these browsers, currently available: 
     // - Chrome 
     // - ChromeCanary 
     // - Firefox 
     // - Opera 
     // - Safari (only Mac) 
     // - PhantomJS 
     // - IE (only Windows) 
     browsers: [ 
      'PhantomJS' 
     ], 

     // Which plugins to enable 
     plugins: [ 
      'karma-phantomjs-launcher', 
      'karma-jasmine' 
     ], 

     // Continuous Integration mode 
     // if true, it capture browsers, run tests and exit 
     singleRun: false, 

     colors: true, 

     // level of logging 
     // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG 
     logLevel: config.LOG_INFO, 

     // Uncomment the following lines if you are using grunt's server to run the tests 
     proxies: { 
      '/views/': '/app/views/', 
      '/index.html': '/app/index.html' 
     } 
     // URL root prevent conflicts with the site root 
     // urlRoot: '_karma_' 
    }); 
}; 

回答

12

根據您的噶的配置,它看起來像你從這個運行項目的根級別。但你的申請是在app/,你的模板是相對到那個路徑......也就是說,你正在訪問/views/nav/offline.html,而不是/app/views/nav/offline.html。 Karma不知道該怎麼做。

嘗試代理:

​​

這將告訴噶治療/視圖/ *請求,彷彿它們是用於/應用/視圖/ *。或者,您可以將您的Karma配置降級到app/本身。然後將包含路徑和其他相關項目更改爲正確的URL,問題就會消失。 (這是我做的。)

+0

嗨乍得,請看我的更新。謝謝! – fiberOptics 2014-09-29 02:08:10

+0

你可以在你的問題中更新你的karma.conf來反映它的當前狀態嗎?目前還不清楚你的所有嘗試包含了哪些內容。 – 2014-09-29 02:46:49

+0

嗨乍得,對不起,我忘了包括配置。請參閱我的編輯。 – fiberOptics 2014-09-29 03:01:39