2015-04-03 17 views
0

我正在寫一個包含刮板的流星包。因此,在我最小的情況下,我需要確保正確地完成對Web資源的請求。用於刮測試的打包資產的URL URL

所以我添加了一個本地資源(一個html文件),我希望通過localhost:3000/{magicpath}/dummywebsite.html運行測試時查詢。我在包中的子文件夾中的測試/文件/ dummywebsite.html

Package.onTest(function(api) { 
    api.use('tinytest'); 
    api.use('packageName'); 

    // test-assets - what is the URL to this asset during testing? 
    api.addFiles(['test/files/dummywebsite.html'], ['client', 'server'], {isAsset: true}); 

    api.addFiles('test/packageName-tests.js', 'server'); 
}); 

我現在尋找了一段時間,嘗試了不同的URL組合訪問該文件添加文件,像這樣tinytest HTML,記者在運行時。有一個相關的流星github-issue discussion關於在測試中使用來自客戶端軟件包的靜態文件......但我無法理解結果。

我想:

http://localhost:3000/packages/author:packagename/test/files/dummywebsite.html 
http://localhost:3000/packages/author_packagename/test/files/dummywebsite.html 
http://localhost:3000/packages/local-test:author:packagename/assets/dummywebsite.html 

但沒有任何結果:(有沒有一些流星忍者知道我可以在測試過程中提供靜態HTML

非常感謝您

回答

1

嗎?謝謝。 @ below9k,但我的問題討論如何訪問在「onTest」期間添加的資產,而不是在一般生產中使用。

同時我找到了答案。要訪問爲onTest部分中的測試用例添加的資產,local-test_需要爲後綴author_package/文件夾。請參閱以下樣本package.js

// Write your package code here! 
Package.describe({ 
    name: "author:package", 
    summary: "A package to find the the url to the unknown depths of onTest static files in a meteor package.", 
    version: "1.0.0" 
}); 

Package.onUse(function (api, where) { 
    api.versionsFrom('0.9.0'); 

    // Asset added during production 
    // http://localhost:3000/packages/author_package/file/production.png 
    // -> Works 
    api.addFiles(['file/production.png'], ['client', 'server'], {isAsset: true}); 

    api.addFiles('test.js', ['client', 'server']); 
}); 

Package.onTest(function(api) { 
    api.use('author:package', ['client', 'server']); 
    api.use(['tinytest', 'test-helpers'], ['client', 'server']); 

    // Asset added onTest. 
    // http://localhost:3000/packages/author_package/file/testing.png 
    // -> Not available. 
    // http://localhost:3000/packages/local-test_author_package/file/testing.png 
    // -> Works, when "local-test_" is prefixed to the package name 
    api.addFiles(['file/testing.png'], ['client', 'server'], {isAsset: true}); 

    // Asset added during production 
    // http://localhost:3000/packages/author_package/file/production.png 
    // -> Works 

    api.addFiles('package-tests.js', ['client', 'server']); 
});