HTML code:
<li class="list-group-item ng-binding ng-scope" ng-repeat="sourceMatch in sourceMatches">
<img ng-src="/static/images/Timesjobs_small.jpg" width="32px" height="32px">
<span class="badge ng-binding">585784</span>
Times Jobs
</li>
我收到此错误。
Expected '52675
Times Jobs' to match '52619 Times Jobs'.
它在第一行显示整数值,在第二行显示文本,因此无法比较。如何解决这个问题?
答案 0 :(得分:0)
getText()总是返回字符串,但你有换行符,在比较之前尝试替换/ n / r
var listItemText = $(li.list-group-item).getText()
.then(function(text){ return text.replace(/[\r\n]/g, "")
expect(listItemText).toMatch('52619 Times Jobs')