我有一个带有多个自定义元素的应用程序,我正在编写测试,而且我不确定如何设置目录以使测试工作。
是这样的:
myApp
myApp/bower_components
myApp/test
myApp/test/myApp
myApp/test/myElement1
myApp/test/myElement2
myApp/test/myElement3
myApp/src
myApp/src/myApp
myApp/src/myElement1
myApp/src/myElement2
myApp/src/myElement3
myApp/demo
或者每个元素都有一个测试/子文件夹吗?像
myApp/src/myElement1/test
myApp/src/myElement2/test
myApp/src/myElement3/test
根据文档here,每个元素都有一个测试文件夹,当您使用聚合物服务时,可以通过浏览器访问该文件夹localhost:8080/components/my-el/test/my-el_test.html
答案 0 :(得分:1)
测试应该在与app主目录分开的自己的文件夹中,以方便Polymer CLI的构建过程。 (让您的应用程序生产准备就绪。)
推荐结构:
myApp / test / myElement1
对myApp / SRC / myElement1
以下是Shop应用程序中的一个示例polymer.json文件:((无测试文件夹))
polymer.json
{
"entrypoint": "index.html",
"shell": "src/shop-app.html",
"fragments": [
"src/shop-list.html",
"src/shop-detail.html",
"src/shop-cart.html",
"src/shop-checkout.html",
"src/lazy-resources.html"
],
"sources": [
"src/**/*",
"data/**/*",
"images/**/*",
"bower.json"
],
"extraDependencies": [
"manifest.json",
"bower_components/webcomponentsjs/webcomponents-lite.js"
],
"lint": {
"rules": ["polymer-2-hybrid"]
}
}