I'm unit testing a jquery plugin using qunit and sinonjs. It works fine in the browser, all tests pass but when I run on the command line using Grunt I get the error "PhantomJS timed out, possible due to a missing QUnit start". The issue is caused by a sinonjs stub I create for window.alert. Can anyone explain what is wrong with my sinon stub? I'm guessing phantomjs is waiting for a response. I have tried QUnit.start() and also tried returning true/false/undefined from my sinon stub.
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;
If I recall correctly, you need to
return true;
(or false) from your stub... I think. At least, that's how I've always seen it, and how various other SO answers have it. So try this: