2016-02-18 105 views
1

這是我第一次使用karma,嘗試啓動測試時遇到一些問題。Karma - base path not working properly

我的文件夾結構如下:

node_modules 
-angular-mocks 
src 
-compiled 
-lib 
-tests 
    -karma.conf.js 

現在,我的karma.conf.js裏面,這是我的文件列表和基本路徑:

module.exports = function (config) { 
    config.set({ 

     basePath: '../../', 

     frameworks: ['jasmine'], 

     files: [ 
      {pattern: 'lib/ionic/js/ionic.bundle.js', included: true, nocache: true, watched: true}, 
      {pattern: 'node_modules/angular-mocks/angular-mocks.js', included: true, nocache: true, watched: true}, 
      'compiled/js/*.js', 
      'compiled/css/*.css', 
      {pattern: 'tests/unit/unit.js', included: true, nocache: true, watched: true} 
    ], 

    exclude: [], 

我打開命令提示符上的另一窗口並使用業力開始運行業力,並且所有瀏覽器都打開並且它們是連接的,而不是如果我鍵入業力運行(雖然業力開始仍在運行),結果如下:

18 02 2016 08:35:26.708:WARN [watcher]: Pattern "c:/src/app/src/tests/src/lib/ionic/js/ionic.bundle.js" does not match any file. 
18 02 2016 08:35:26.708:WARN [watcher]: Pattern "c:/src/app/src/tests/src/angular-mocks/angula-mocks.js" does not match any file. 
18 02 2016 08:35:26.708:WARN [watcher]: Pattern "c:/src/app/src/tests/src/compiled/js/*.js" does not match any file. 
18 02 2016 08:35:26.708:WARN [watcher]: Pattern "c:/src/app/src/tests/src/compiled/css/*.css" does not match any file. 
18 02 2016 08:35:26.708:WARN [watcher]: Pattern "c:/src/app/src/tests/src/tests/unit/unit.js" does not match any file. 

我可以看到文件路徑是錯誤的,但我不明白爲什麼...任何幫助?

非常感謝

回答

0

對於未來的讀者:使用basePath: process.cwd()