Sinon 存根超时 Phantomjs
sinon stub timing out phantomjs
我正在使用qunit和sinonjs对jquery插件进行单元测试。它在浏览器中工作正常,所有测试都通过,但是当我使用 Grunt 在命令行上运行时,我收到错误"PhantomJS 超时,可能是由于缺少 QUnit 启动"。该问题是由我为 window.alert 创建的 sinonjs 存根引起的。谁能解释一下我的 sinon 存根有什么问题?我猜 phantomjs 正在等待响应。我尝试过 QUnit.start(),也尝试从我的 sinon 存根返回真/假/未定义。
QUnit.test('test options exist and default values', function( assert ) {
// Stub the winow alert method using sinon.
var alertStub = sinon.stub(window, "alert", function(msg) { return true; } );
$('#target').formdialog();
// Assert a dialog window opened, caused by the lack of parameters passed
sinon.assert.called(window.alert);
// Grab the jQuery plugin data assigned to the DOM element.
var options = $('#target').data('gten-formdialog').options;
如果我
没记错的话,你需要从你的存根中return true;
(或假)......我认为。至少,我一直是这样看待它的,以及其他各种SO答案是如何看待它的。所以试试这个:
QUnit.test('test options exist and default values', function( assert ) {
// Stub the winow alert method using sinon.
var alert = sinon.stub(window, "alert", function(msg) { return true; } );
$('#target').formdialog();
// Assert a dialog window opened, caused by the lack of parameters passed
sinon.assert.called(window.alert);
// Grab the jQuery plugin data assigned to the DOM element.
var options = $('#target').data('gten-formdialog').options;
相关文章:
- 我如何才能让CasperJS和PhantomJS在约塞米蒂玩得很好
- 使用优化器在慢速连接上加载main.js时需要js超时
- PhantomJS - 检查javascript函数是否正在运行的任何方法
- PhantomJS重影驱动程序停止
- “;出口;在PhantomJS中定义
- 当浏览器控制台未打开时,为什么要求会导致Internet Explorer 9超时
- 超时功能的性能
- 在page.open()-PhantomJS中无法访问全局变量
- 使用不同的超时对数组中的每个项目进行角度动画处理
- 设置第一次执行的超时
- node.js测试事件是否是在不使用超时的情况下使用sinon.js发出的
- PhantomJS(vs nightwatch.js)设置cookie错误
- 使用javascript和随机暂停/超时快速循环文本
- PhantomJS并没有在每次加载页面时进行所有AJAX调用
- 如何在jQuery事件处理程序中存储和重用超时
- 当定位模式设置为“0”时,总是达到关于地理定位的超时;仅设备”;
- 为什么页面重新加载会使设置超时无效,以及如何避免
- 立即设置超时
- Sinon 存根超时 Phantomjs
- selenium-webdriver和phantomJS中的等待超时错误