Polymer / tools

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

Tests which have dom-module and template defined in test file itself, don't work in firefox #2958

Open mvuksano opened 9 years ago

mvuksano commented 9 years ago

I have a test which is of the following structure:

<dom-module is="x-test-module>
  <template>...</template>
  <script>
    Polymer({
      is: 'x-test-module',
     ... 
    });
  </script>
</dom-module>

<test-fixture id="TestFixture">
  <template>
    <x-test-module id="testModule"></x-test-module>
  </template>
</test-fixture>

And when I run this tests they cause an exception in Firefox (while working just fine in Chrome):

Polymer is not defined
  <unknown> at file_path_to_test_file.html:xx

I also made sure to import

<script src="../bower_components/webcomponentsjs/webcomponents-lite.js"></script>
dmaslov commented 9 years ago

You may also try to import <script src="../bower_components/web-component-tester/browser.js"></script>

mvuksano commented 9 years ago

@dmaslov That's imported too.

ankon commented 8 years ago

The issue still exists with Firefox 44 and Safari 9.0.3 on Mac OS X 10.11.4: tests work when the element is defined in a separate file, but don't work when it is defined inside the test HTML file.

btelles commented 8 years ago

FWIW, I found an ugly work-around. Wait for the 'webComponentsReady' event to fire on every test.

window.addEventListener('WebComponentsReady', (e) => {
  Polymer/WebCompontentTester tests...
});
yebrahim commented 6 years ago

Anyone figured out why this happens on Firefox? I'm seeing the same issue, and @btelles' hack fixes it.

justinfagnani commented 6 years ago

This is just same problem of main page element definitions without native HTML Imports, because we can't make main page scripts wait. WCT already waits to run tests until WebComponentsReady, so I'd just put the element definition in a wait too. You shouldn't need to do that for every test.

yebrahim commented 6 years ago

@justinfagnani, For my scenario, the test itself needs to wait, because it's using native HTML imports to load some vanilla Javascript, and it doesn't make sense to make that Javascript wait for the WebComponetsReady event.

Btw, is there a discussion thread on element definitions without native HTML imports that you can link to?

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.