2014-04-09 38 views
4

無法在使用業力時爲我的測試加載模板固件。爲了簡化,Karma的基目錄位置

又到C:\

創建一個1.txt的文本文件。使用

basePath: '', 

開始因緣:

C:\> karma start .\sample.conf.js 

瀏覽器在打開:

http://localhost:9876/?id=49209467 

然後我試圖轉到:

由包含簡單的卡拉馬init文件

http://localhost:9876/base/1.txt 

,但得到了在瀏覽器中的「未找到」錯誤消息,並且從因果報應的消息:

WARN [web-server]: 404: /base/1.txt 

缺少什麼我在這裏?

回答

5

找到了答案:

加入以下的業力配置文件:

files: [ 
.... 
{ pattern: 'mocks/**/*.html', watched: true, served: true, included: false }, 
.... 

我設法通過瀏覽

http://localhost:9876/base/mocks/file.html 
+0

你能解釋一下什麼是訪問所需文件線呢? – nottinhill

+0

@SirBenBenji - 它允許Karma爲'mocks/file.html'添加資源映射並將其添加到爲其'basePath'配置的任何內容。在這種情況下,'basePath'配置爲一個空字符串,所以Karma默認爲'http:// localhost:9876/base'。所以最終的結果是'http:// localhost:9876/base/mocks/file.html' – Barry

+2

如果你碰巧在瑞士,我會給你買一瓶啤酒!我處在一個問題上咬我的桌子邊緣。 – n3utrino