I am trying to insert data into the test fixture but couldn't achieve so far. Returns this error:
    "was given a model to stamp, but the template is not of a bindable type"
My test code is like below:
<test-fixture id="myFixture">
  <template is="dom-template">
    <my-element given-input="[[selectedInput]]"></myElement>
  </template>
</test-fixture>
<script>
  suite('<my-element>', function() {
    var myEl;
    setup(function() {
      myEl = fixture('myFixture', {selectedInput: 'test input'});
    });
    test('initiates my-element', function() {
      // fails as givenInput returns "[[selectedInput]]"
      assert.equal(myEl.givenInput, 'test input');
    });
  });
</script>
Similar question was asked here polymer 1.0 unit tests - how to bind properties to a child element? but the answer is not what I look for since it is directly defining target property in the child element
Also in Data binding in Polmyer's <test-fixture> it is very same issue but didn't work for me either.
My question is about, how can we pass a property down to the element through test fixture in Polymer 2.x unit testing?
After some more research, I found out that this was an already known issued which can be tracked here https://github.com/PolymerElements/test-fixture/issues/47.
The only possible workaround I have found to continue with the unit testing is to pass givenInput into myEl and removing given-input="[[selectedInput]]" from my-elemet inside test-fixture. Which is not the proper approach but at least makes testing possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With