2.x unit test polymer passes optional binding content for binding to the target property

I am trying to insert data into test equipment, but so far have not been able to achieve. Returns this error: "was given a model to stamp, but the template is not of a bindable type"

My test code is as follows:

 <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> 

A similar question was asked here unit 1.0 unit tests - how to bind properties to a child? but the answer is not the one I am looking for as it directly defines target in the child

Also data binding in Polmyer <test-fixture> is a very problem, but also does not work for me.

My question is, how can we pass a property to an element through a test device in testing Polymer 2.x modules?

+5
source share
1 answer

After several more studies, I found out that this is already a well-known publication, which can be traced here https://github.com/PolymerElements/test-fixture/issues/47 .

The only possible workaround I found to continue unit testing was to pass givenInput to myEl and remove given-input="[[selectedInput]]" from my-elemet inside test-fixture . This is not the right approach, but at least makes testing possible.

+3
source

Source: https://habr.com/ru/post/1270075/


All Articles