Javascript 为什么Jasmine在我的页面上找不到字符串
我正在写一些Jasmine测试,Javascript 为什么Jasmine在我的页面上找不到字符串,javascript,jasmine,Javascript,Jasmine,我正在写一些Jasmine测试,toContain在页面上找不到字符串。以下是其中之一: it('should contain Superhero', function() { expect(el).toContain('Superhero'); }); 以下是el的值,它是Jquery对象: 还有,这里是业力中的错误: Chrome 32.0.1700 (Mac OS X 10.8.5) marvelApp directives detail.window.directiv
toContain
在页面上找不到字符串。以下是其中之一:
it('should contain Superhero', function() {
expect(el).toContain('Superhero');
});
以下是el
的值,它是Jquery
对象:
还有,这里是业力中的错误:
Chrome 32.0.1700 (Mac OS X 10.8.5) marvelApp directives detail.window.directive should contain Superhero FAILED
TypeError: Object [object Object] has no method 'indexOf'
at null.<anonymous> (/Users/mhamm/Developer/marvel/test/mainCtrlSpec.js:61:20)
Chrome 32.0.1700 (Mac OS X 10.8.5): Executed 1 of 0 (1 FAILED) ERROR (0 secs / 10 mins 37.377 secs)
Chrome 32.0.1700(Mac OS X 10.8.5)marvelApp指令detail.window.directive应包含Superhero失败
TypeError:对象[Object]没有方法“indexOf”
在空。(/Users/mhamm/Developer/marvel/test/mainCtrlSpec.js:61:20)
Chrome 32.0.1700(Mac OS X 10.8.5):执行0(1失败)错误中的1(0秒/10分钟37.377秒)
为什么《茉莉花》
在《我的el
中看不到超人的价值观 方法toContain
要求函数expect
得到一个字符串,而不是jQuery对象:
it('should contain Superhero', function() {
expect(el.html()).toContain('Superhero');
});
这就是为什么会出现此错误:
[object object]没有方法“indexOf”
[object object]没有方法“indexOf”
it('should contain Superhero', function() {
expect(el.text()).toContain('Superhero');
});