我刚刚查看了 R2D3来自 github,现在我想运行测试。我是这个存储库的新手,也不是 JS 测试方面的专家,但认为执行此操作的正确方法是查看 tests/index.html在 Web 浏览器中,查看 QUnit 测试是否通过。
但是,当我尝试执行此操作时,52 个测试中有 41 个直接失败(在 OSX 上的 Chrome、Firefox 和 Safari 中):
我从开发者工具中可以看到所有文件都正确加载,因此不仅仅是路径错误。查看代码表明 .append()
失败。前两个错误位于 line 16在 tests/core/append-tests.js
中:var el = svg.append('image')
和 line 20 : var el = svg.append('line')
。
追踪问题back to the root in r2d3.v2.js
,问题似乎出在这两个函数上:
Raphael.fn.appendChild = function(childNode) {
var node = this.buildElement(childNode);
if (node) {
this.shadowDom.appendChild(childNode);
node.updateStyle(); // Apply CSS styles
}
return node;
};
Raphael.fn.buildElement = function(childNode) {
var type = childNode && childNode.nodeName,
node = type ? this[type.toLowerCase()]() : null;
if (node) {
// Ensure Paper can be referenced from sets
node.shadowDom = childNode
node.parentNode = this;
// Link the shadowDOM node by the Raphael id.
node.shadowDom.r2d3 = true;
node.shadowDom.r2d3id = r2d3UID();
node.paper = this;
node.tagName = type.toLowerCase();
node.style = new ElementStyle(node);
r2d3Elements[node.shadowDom.r2d3id] = node;
}
return node;
}
但是,我的调试能力已经无法再进一步了。谁能建议可能出了什么问题?
最佳答案
看起来您正在使用 Chrome 运行 qunit 测试。 R2D3 仅针对 IE 构建。
关于javascript - R2D3 的 QUnit 测试开箱即用失败 - 我做错了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15199544/