1

I've got an app with several custom elements in it, and I'm writing tests, and I'm not sure how the directories are supposed to be set up for tests to work.

Is it something like:

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

Or does each element get a test/ subfolder? Like

myApp/src/myElement1/test
myApp/src/myElement2/test
myApp/src/myElement3/test

According to the docs here each element has a test folder that can be accessed via the browser when you use polymer serve like so localhost:8080/components/my-el/test/my-el_test.html

Bobby Battista
  • 1,985
  • 2
  • 17
  • 27

1 Answers1

1

The test should be in their own folder separated from the app main directory to facilitate the Polymer CLI's build process. (Making your app production ready.)

Recommended Structure:
myApp/test/myElement1
myApp/src/myElement1

Here’s an example polymer.json file from the Shop app: ((No Test Folder))

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"]
  }
}
JoelCode
  • 326
  • 1
  • 7
  • Thanks Joel. So when I want to take the browser to localhost:8080/components/my-el/test/my-el_test.html does Polymer know to look at /test/my-el/my-el_test.html? Even though the url doesn't have the same structure? – Bobby Battista Mar 14 '17 at 19:11
  • This is a good question, unfortunately, I do not know the answer. – JoelCode Mar 15 '17 at 06:04