小编use*_*387的帖子

Polymer 2.x unit test将可选内容传递给fixture,以便绑定到target属性

我试图将数据插入测试夹具但到目前为止无法实现.返回此错误: "was given a model to stamp, but the template is not of a bindable type"

我的测试代码如下:

<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>
Run Code Online (Sandbox Code Playgroud)

类似的问题在这里被问到聚合物1.0单元测试 - 如何将属性绑定到子元素?但答案不是我想要的,因为它直接定义了子元素中的目标属性

同样在Polmyer的<test-fixture>中的数据绑定中,这是非常相同的问题,但对我来说也不起作用.

我的问题是,如何通过Polymer 2.x单元测试中的测试夹具将属性传递给元素?

html unit-testing polymer-2.x

5
推荐指数
1
解决办法
335
查看次数

标签 统计

html ×1

polymer-2.x ×1

unit-testing ×1