2015-04-03 18 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']); 
});