[英]How Do I Find the Script SRC in Jasmine
我是Jasmine的新手,正尝试编写一个单元测试,以检查是否根据环境定义的变量正确构建了URL。
describe('URL is built properly', function() {
var newHead = '<!doctype html>' +
'<html class="no-js" lang="">' +
' <head>' +
' </head>' +
'<body>' +
'</body>' +
'</html>';
beforeEach(function() {
ScratchPad.clear();
ScratchPad.add(newHead);
debugger;
spyOn(newSetup.prototype, 'createNewScript');
});
afterAll(function() {
ScratchPad.clear();
});
it('should build Staging', function() {
window.my.env = 'staging';
window.my = {
newScript: {
enabled: true,
location: 'google-com'
}
};
var options = {
windowWidth: 640
};
this.newScript = new newScriptSetup(options);
var newHTML = ScratchPad.find('script')[0].src;
debugger;
expect(newHTML.src).toEqual('http://my.site.com/google-com/myScript.min.js');
});
});
我似乎遇到的问题是;
expect(newHTML.src).toEqual('http://my.site.com/google-com/myScript.min.js');
这部分脚本没有被填充,我已经尝试调试它,并且正在创建var newHead,其余的单元测试只是看不到它...我想。 有人可以帮我吗,我整天都在看着它:(
var newHTML = ScratchPad.find('script')[0].src;
debugger;
expect(newHTML.src)..
您已经在newHTML中获得了src
。 您正在尝试使用提供的URL检查.src.src。 尝试这个:
var newHTML = ScratchPad.find('script')[0].src;
expect(newHTML).toBe(..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.