cybernetlab / karma-polymer

Karma adapter for Polymer framewrok
2 stars 6 forks source link

Cannot use polymer.create(). Its callback doesn't get called. #3

Open haxpor opened 7 years ago

haxpor commented 7 years ago

I need to have the following test suite code in jasmine to make it works

beforeAll(function(done) {
   window.addEventListener('WebComponentsReady', function(e) {
      console.log("WebComponents is ready");

      stockticker = document.createElement('stock-ticker');
      stockticker.setAttribute('symbols', '["GOOG", "GOOGL"]');
      stockticker.setAttribute('id', id_name);
      document.body.appendChild(stockticker);

      // get element now and use it throughout test case
      //to_check = document.getElementById(id_name);
      to_check = document.getElementById(id_name);

      done();
   });
});

polymer.create('stock-ticker', function(el) { ... }) - its callback function is not getting called. Thus I have to rely on pure javascript to write testing code as seen above.

I have to wrap my testing code inside WebComponentsReady event. I then can safely create a new element thus each test case will be able to call component's member functions.

PS. This info might be needed as my component spans into 2 files: .js and .html. Thus when include into karma.conf.js, I need to write config file as seen in this comment.

divanvisagie commented 7 years ago

Been having the same issue here.