我正在尝试测试一堆页面的功能(例如模拟点击、检查类附加等),并认为 phantomjs 将是我测试的好主机。
虽然我一生无法弄清楚如何结合 qunit 和 phantomjs。(我也在尝试通过 Grunt 的 qunit 模块运行它)
我想我可以做这样的事情,混合幻像和 qunit 语法......
var page = require('webpage').create();
page.viewportSize = { width: 1280, height: 1024 };
page.onConsoleMessage = function (msg) {
console.log(msg);
};
page.open('home.html', function () {
module("tests");
test('test', 1, function(){
$('#button').on('click', function(){
ok(true, 'button was clicked!');
});
$('#button').trigger('click');
});
});
但显然这确实是错误的。
是否将我的页面内容注入到我的 test.html 文件中的 qunit-fixture div 中?还是我完全走错了路?