我有一个指令在单元测试中呈现以下 html:
<div id="published-envs">
<strong>Published to</strong>
<!-- ngRepeat: env in fundConfigurationVersion.publicationEnvironments --><div data-ng-repeat="env in fundConfigurationVersion.publicationEnvironments" class="ng-binding ng-scope">
QA (Jan 29, 2015)
</div><!-- end ngRepeat: env in publicationEnvironments --><div data-ng-repeat="env in publicationEnvironments" class="ng-binding ng-scope">
PROD (Jan 30, 2015)
</div><!-- end ngRepeat: env in publicationEnvironments -->
</div>
我试图抓住<div id="published-envs">
并断言它有两个 child <div>
。
我尝试了以下方法,但它不起作用:
var environments = element.find('#published-envs'); //comes back empty
在角度单元测试中按 id 查找元素的正确方法是什么?