firefox addon-sdk 单元测试
有人使用过 addon-sdk(cfx 测试)中的单元测试吗?
我做了一个如下所示的测试:
exports.test_open_tab = function(test) {
const tabs = require("tabs");
tabs.open({
url: "http://valid url with lots of params",
onReady: function(tab) {
test.done();
}
});
test.waitUntilDone(600*1000);
};
基本上应该打开一个选项卡,等待 600 秒,然后将其标记为通过。
它实际上在控制台中显示来自加载页面的许多错误和警告(jquery 和 google 分析内容,由加载页面使用),然后将测试标记为失败。
知道为什么吗?
Did anybody used the unit-tests from the addon-sdk(cfx test)?
I made a test that looks like this:
exports.test_open_tab = function(test) {
const tabs = require("tabs");
tabs.open({
url: "http://valid url with lots of params",
onReady: function(tab) {
test.done();
}
});
test.waitUntilDone(600*1000);
};
basically this should open a tab, wait 600seconds, and them mark it as passed.
It actually displays a lot of errors and warning in the console from the loaded page(jquery and google analytics stuff, used by the loaded page) and then it marks the test as failed.
Any idea why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个明显的问题是您实际上没有任何测试结果。如果调用
onReady()
的事实是一个肯定的结果,您应该这样写:顺便说一句,唯一会等待 600 秒的情况是如果未调用
onReady
出于某种原因。否则,您的test.done()
调用将完成测试执行。您可以通过禁用 来减少记录的警告数量
javascript.options.strict
首选项。然而,这些警告可能表明真正的问题,并且在当前的 Firefox 版本中,关闭控制台中 JavaScript 和 CSS 警告的显示可能更有意义。One obvious issue is that you don't actually have any test results. If the fact that
onReady()
is called is a positive result you should write:Btw, the only case where it would wait 600 seconds is if
onReady
isn't called for some reason. Otherwise yourtest.done()
call will complete the test execution.You can somewhat reduce the number of warnings logged by disabling
javascript.options.strict
preference. However, these warnings might indicate real issues and in current Firefox versions it probably makes more sense to switch off display of JavaScript and CSS warnings in the console.