单击不会在qUnit测试中打开详细视图(使用ember-testing)

时间:2013-06-20 14:37:14

标签: ember.js qunit

我有一个我想要测试的主/详细页面。有一个things列表,当您单击时会显示thing的路由。

以下测试找到要点击的thing,但似乎没有点击它。

@exists = (selector) ->
  !!find(selector).length

...

test "things expand to show a detail view", 1, ->
   visit("/").then(->
     click(".things li:contains('Example Thing')")
   ).then ->
     ok(@exists("h2")) # a tag in the detail view

...

<ul class='things'>
  {{#each controller}}
    <li>{{#linkTo 'thing' this}}{{title}}{{/linkTo}}</li>
  {{/each}}
</ul>

{{outlet}}

...

<div class='thing'>
  <h2>{{title}}</h2>
</div>

这引起了:Failure/Error: Element h2 not found.有人知道我错过了什么/如何让这个测试通过吗?

我在浏览器中使用茶匙(以前称为teabag)作为测试运行器,如果这有所不同。我是否能够在测试点击时看到发生的互动?

1 个答案:

答案 0 :(得分:0)

您不应该点击<li>元素,而是点击<a>元素。 手柄中的linkTo助手会在DOM中生成<a>标记。

click(".things li:contains('Example Thing') a ")这样的东西应该有效。