Polymer / tools

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

Failed to execute 'registerElement' on 'Document': Registration failed for type 'test-fixture'. A type with that name is already registered. #2996

Closed btelles closed 5 years ago

btelles commented 8 years ago

Tests failing because test-fixture is already registered on Chrome.

Steps to reproduce:

  1. git clone https://github.com/PolymerElements/polymer-starter-kit.git myApp
  2. cd myApp
  3. npm install -g gulp bower && npm install && bower install
  4. gulp test:local

Expected result: All tests pass on chrome (version 46) and firefox (version 25) browsers

Actual result: Tests fail on Chrome and Pass on Firefox. Here are the results:

gulp test:local
[10:29:35] Using gulpfile ~/development/testApp/gulpfile.js
[10:29:35] Starting 'wct:local'...
Installing and starting Selenium server for local browsers
Selenium server running on port 33313
Web server running on port 2000 and serving from /usr/local/home/me/testApp
chrome 46                Beginning tests via http://localhost:2000/components/testApp/generated-index.html?cli_browser_id=0
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/testApp/bower_components/test-fixture/test-fixture.html:312:0
    <unknown> at   <unknown> at /components/testApp/bower_components/test-fixture/test-fixture.html:315:0

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/testApp/bower_components/test-fixture/test-fixture.html:312:0
    <unknown> at   <unknown> at /components/testApp/bower_components/test-fixture/test-fixture.html:315:0

chrome 46                Tests failed: 2 failed tests
firefox 25               Beginning tests via http://localhost:2000/components/robot/generated-index.html?cli_browser_id=1
firefox 25               Tests passed
Test run ended in failure: 2 failed tests

chrome 46 (2/0/2)                       firefox 25 (2/0/0)                    
[10:29:49] 'wct:local' errored after 15 s
[10:29:49] Error: 2 failed tests
btelles commented 8 years ago

It appears the line:

  <link rel="import" href="../../bower_components/test-fixture/test-fixture.html">

is not necessary?

ghost commented 8 years ago

Had the same issue... Here's what worked for me: https://github.com/PolymerElements/test-fixture/issues/20

mdgrech commented 8 years ago

This issue is fixed in the new version of the polymer starter kit. Removing the link from the 2 test files fixed the problem for me.

btelles commented 8 years ago
The work-around by @mdgrech is very limited.

And the work-around by @BorntraegerMarc is the same one.

If I then try and import something from bower components in my test (in particular, I'm trying to import iron-ajax), the test continues to fail in the same manner. I've also tried importing iron-ajax in a variety of ways (changing load order, placing the import inside a new special_elements.html file, and changing the server pathMappings in wct).

This is quite a show stopper for using WCT for me. I had to manually create AJAX requests in my tests.

Here are the revised steps that work with the latest clone from polymer-starter-kit:

  1. git clone https://github.com/PolymerElements/polymer-starter-kit.git myApp
  2. cd myApp
  3. npm install -g gulp bower && npm install && bower install && gulp
  4. Add the following line to app/test/my-greeting-basic.html: <link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
  5. gulp test:local

Expected result: All tests pass on chrome (version 46) and firefox (version 25) browsers

Actual result: Tests fail on Chrome and Pass on Firefox. Here are the results:

Installing and starting Selenium server for local browsers
Selenium server running on port 48723
Web server running on port 2000 and serving from /home/btelles/code/polymer-starter-kit
chrome 46                Beginning tests via http://localhost:2000/components/polymer-starter-kit/generated-index.html?cli_browser_id=0
chrome 46                ✖ 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:308:0
    <unknown> at   <unknown> at /components/polymer-starter-kit/app/bower_components/polymer/polymer-micro.html:323:0

chrome 46                ✖ Test Suite Initialization

  Polymer.Base._getExtendedPrototype is not a function
    <unknown> at          desugar at /components/polymer-starter-kit/app/bower_components/polymer/polymer-micro.html:71:0
    <unknown> at   window.Polymer at /components/polymer-starter-kit/app/bower_components/polymer/polymer-micro.html:58:0
    <unknown> at        <unknown> at /components/polymer-starter-kit/app/bower_components/polymer/polymer.html:3512:0
    <unknown> at        <unknown> at /components/polymer-starter-kit/app/bower_components/polymer/polymer.html:3579:0

chrome 46                ✖ Test Suite Initialization

  this._desugarBehaviors is not a function
    <unknown> at   HTMLElement.Polymer.Base.registerCallback at /components/polymer-starter-kit/app/bower_components/polymer/polymer-micro.html:181:0
    <unknown> at                                    desugar at /components/polymer-starter-kit/app/bower_components/polymer/polymer-micro.html:74:0
    <unknown> at                             window.Polymer at /components/polymer-starter-kit/app/bower_components/polymer/polymer-micro.html:58:0
    <unknown> at                                  <unknown> at /components/polymer-starter-kit/app/elements/my-greeting/my-greeting.html:30:0
    <unknown> at                                  <unknown> at /components/polymer-starter-kit/app/elements/my-greeting/my-greeting.html:41:0

chrome 46                ✖ app/test/my-greeting-basic.html » my-greeting tests » Welcome!

  Cannot read property 'textContent' of null
    <unknown> at   Context.<anonymous> at my-greeting-basic.html:43:0

chrome 46                Tests failed: 4 failed tests
Test run ended in failure: 4 failed tests

chrome 46 (1/0/4)                     
dfreedm commented 8 years ago

Fixed with test-fixture 1.1.0