问题描述
因此,首先我阅读了此堆栈溢出问题,它看起来没有就像我的同一个问题.
So first I have read this Stack Overflow question and it doesn't look like my same issue.
基本上,我正在尝试使用Mocha和 Zombie.js 在我的Node.js上运行一些测试网站.
Basically I'm trying to use Mocha and Zombie.js to run some tests on my Node.js site.
我正在尝试检查是否可以创建用户.最后,我想检查一下我的引导程序模式是否存在.基本上,我将引导程序模式包装在EJS if
语句中,因此绝对有可能不存在该模式.这就是为什么我要在上面运行测试的原因.
I'm trying to check to see if I can create a user. In the end I would like to check to see if my bootstrap modal exists. Basically I have the bootstrap modal wrapped in an EJS if
statement so there is defiantly a chance it might not exist. So that is why I'm trying to run tests on it.
但是目前它甚至不能与browser.assert.success();
一起使用,因此我目前只是在尝试检查元素之前尝试解决此问题.
But currently it's not even working with browser.assert.success();
so I'm currently just trying to solve this before moving on to checking for elements.
browser.visit('/login', function() {
browser.fill('email', '[email protected]');
browser.fill('password', 'testtest');
browser.pressButton('Login').then(function() {
browser.assert.success();
}).then(done, done);
});
在这种情况下,我应该在浏览器当前所在的页面上运行以下代码.
In this case I should be running the following code on the page the browser is currently on.
<script>
$("#paymentModal").modal('show');
</script>
运行此单元测试时,它给我以下错误.
When running this unit test it gives me the following error.
https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:3
}return c}function Q(a){var b;for(b in a)if(("data"!==b||!n.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function R(a,b,d,e){if(M(a)){var f,g,h=n.expando,i=a.nodeType,j=i?n.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||n.guid++:h),j[k]||(j[k]=i?{}:{toJSON:n.noop}),"object"!=typeof b&&"function"!=typeof b||(e?j[k]=n.extend(j[k],b):j[k].data=n.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[n.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[n.camelCase(b)])):f=g,f}}function S(a,b,c){if(M(a)){var d,e,f=a.nodeType,g=f?n.cache:a,h=f?a[n.expando]:n.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){n.isArray(b)?b=b.concat(n.map(b,n.camelCase)):b in d?b=[b]:(b=n.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!Q(d):!n.isEmptyObject(d))return}(c||(delete g[h].data,Q(g[h])))&&(f?n.cleanData([a],!0):l.deleteExpan
TypeError: j.getClientRects is not a function
at k (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:3:26891)
at Object.n.extend.pixelMarginRight (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:3:25936)
at a.getComputedStyle.Sa (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:3:27592)
at Function.n.extend.css (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:3:30895)
at https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:4:520
at Y (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:3:4661)
at n.fn.extend.css (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:4:361)
at c.setScrollbar (http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js:6:18612)
at c.show (http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js:6:14692)
at .<anonymous> (http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js:6:13878)
在我看来,由于某些原因,Zombie.js没有在该页面上加载jQuery或出现错误.但是在前面的堆栈溢出问答中,似乎Zombie.js可以加载jQuery.
Looks to me like for some reason Zombie.js isn't loading jQuery on that page or there is an error. But in that previous Stack Overflow question and answer at the beginning of the question it looks like Zombie.js can load jQuery.
您是否无法使用Zombie.js加载jQuery?我怎样才能解决这个问题?用jQuery测试页面似乎很简单.有什么想法吗?
Are you not able to load jQuery with Zombie.js? How can I fix this? Seems like a very simple thing to test pages with jQuery. Any ideas?
让我知道您是否需要任何其他信息或其他任何信息.谢谢.
Let me know if you need any additional information or anything. Thanks.
编辑出于某种原因,降级到jQuery版本1.11.3
似乎可行,并且错误消失了.有什么原因吗?
EDIT for some reason when downgrading to jQuery version 1.11.3
it seems to work and the error goes away. Any reason for this?
推荐答案
此错误已修复: https://github.com/assaf/zombie/issues/1031
添加getClientRects()的存根实现非常简单.我已经发布了5.0.1,其中包含针对此特定失败的修复程序.
Add a stub implementation of getClientRects() was straightforward. I've published 5.0.1 with a fix for this specific failure.
mdlavin
这篇关于Zombie.js jQuery加载错误"j.getClientRects不是函数"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!