Polymer / tools

Polymer Tools Monorepo
BSD 3-Clause "New" or "Revised" License
430 stars 200 forks source link

registrationError when including project and bower_components elements #2975

Open pengying opened 8 years ago

pengying commented 8 years ago

I'm getting

chrome 45                ✖ Test Suite Initialization
  Failed to execute 'registerElement' on 'Document': Registration failed for type 'dom-module'. A type with that name is already registered.
    <unknown> at   <unknown> at /components/polymer-starter-kit/app/bower_components/polymer/polymer-micro.html:263:0
    <unknown> at   <unknown> at /components/polymer-starter-kit/app/bower_components/polymer/polymer-micro.html:273:0

When including elements from the local project elements directory and bower_components

  <link rel="import" href="../../bower_components/paper-dialog/paper-dialog.html">
  <!-- Import the element to test -->
  <link rel="import" href="../elements/my-greeting/my-greeting.html">

To repro: clone polymer-start-kit bower install PolymerElements/paper-dialog include paper dialog in tests/my-greeting-basic.html start test and get error

jbastow commented 8 years ago

@pengying I found a work around for now, seems to be a problem with the bower web-component-tester package. I'm using the yeoman polymer-generator, but it is also based off polymer-starter-kit so it should apply here. Make sure npm install has been run to get web-component-tester from npm.

In all the test files in the test/ directory e.g. tests/my-greeting-basic.html, change the script import for web-component tester to reference from node_modules instead of bower_components:

Find:

  <script src="../../bower_components/web-component-tester/browser.js"></script>

and change to:

  <script src="../../node_modules/web-component-tester/browser.js"></script>

Does the problem still persist after that? If so, could it to do with importing paper-dialog in the tests/my-greeting-basic.html file directly instead of as an import inside of elements/my-greeting/my-greeting.html?

pengying commented 8 years ago

Yeah the problem still occurs. I diffed the two browser.js and they're the same for me.

andyfinity commented 8 years ago

@pengying, I experienced a very similar problem to yours. Specifically, my errors looked like this for Chrome (but not Firefox):

chrome 46                ✖ Test Suite Initialization
  Failed to execute 'registerElement' on 'Document': Registration failed for type 'test-fixture'. A type with that name is already registered.
    <unknown> at   <unknown> at /components/demo-web-app/bower_components/test-fixture/test-fixture.html:312:0
    <unknown> at   <unknown> at /components/demo-web-app/bower_components/test-fixture/test-fixture.html:315:0

My workaround was to comment out the import to test-fixture.html in my tests. It seems as though they're already imported somewhere and the deduplication of imports isn't being done properly. Perhaps you are importing polymer-micro.html somewhere in your tests?

Strangely enough, Firefox worked fine. It's just Chrome that was complaining. Something something shadow DOM, perhaps? Beats me...

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.