(Cross-posted from http://stackoverflow.com/questions/22819736/null-is-not-an-object-when-running-jasmine-tests-via-chutzpah.)
I'm beating my head against a wall running some Chutzpah tests. I have a web page (https://payboardbeta.azurewebsites.net/widget/v1.0/test/PayboardTests.html, if you're interested) that has my JS unit tests, written using Jasmine. The tests all pass if I run the page in a browser (whether on my machine or any other that I've tried), and they similarly all pass if I run them via Chutzpah on my local dev machine. However, they fail with the following error message if I run them via Chutzpah (chutzpah.console.exe https://payboardbeta.azurewebsites.net/widget/v1.0/test/PayboardTests.html) on my build server.
This is the test in question:
Any suggestions for troubleshooting this?
I'm beating my head against a wall running some Chutzpah tests. I have a web page (https://payboardbeta.azurewebsites.net/widget/v1.0/test/PayboardTests.html, if you're interested) that has my JS unit tests, written using Jasmine. The tests all pass if I run the page in a browser (whether on my machine or any other that I've tried), and they similarly all pass if I run them via Chutzpah on my local dev machine. However, they fail with the following error message if I run them via Chutzpah (chutzpah.console.exe https://payboardbeta.azurewebsites.net/widget/v1.0/test/PayboardTests.html) on my build server.
Error: TypeError: 'null' is not an object (evaluating 'activeTestCase.timetaken = timetaken')
in phantomjs://webpage.evaluate() (line 87)
at dispatch in https://payboardbeta.azurewebsites.net/Scripts/jasmine/jasmine.js (line 1566)
in https://payboardbeta.azurewebsites.net/Scripts/jasmine/jasmine.js (line 1549)
at specResultCallback in https://payboardbeta.azurewebsites.net/Scripts/jasmine/jasmine.js (line 677)
at complete in https://payboardbeta.azurewebsites.net/Scripts/jasmine/jasmine.js (line 330)
at clearStack in https://payboardbeta.azurewebsites.net/Scripts/jasmine/jasmine.js (line 506)
in https://payboardbeta.azurewebsites.net/Scripts/jasmine/jasmine.js (line 1505)
in https://payboardbeta.azurewebsites.net/Scripts/jasmine/jasmine.js (line 1517)
in https://payboardbeta.azurewebsites.net/Scripts/jasmine/jasmine.js (line 287)
in https://payboardbeta.azurewebsites.net/widget/v1.0/test/EventsTests.js (line 265)
in https://payboardbeta.azurewebsites.net/widget/v1.0/Payboard.js (line 247)
While Running:https://payboardbeta.azurewebsites.net/widget/v1.0/test/PayboardTests.html
Error: Timeout occured when executing test file
While Running:https://payboardbeta.azurewebsites.net/widget/v1.0/test/PayboardTests.html
I should note again that exactly the same command-line works correctly on my dev box.This is the test in question:
it('should should submit form even if server never resolves', function (done) {
Payboard.Events.setSampleGroupId(80);
Payboard.Events.setPercentToTrack(90);
var event = {
target: { submit: function () {
done(); // <-- THIS IS WHERE IT FAILS
}
},
preventDefault: function () { }
};
Payboard.Events.onSubmit(event, 100);
// server.respond(); ** Make sure we don't resolve
});
It fails somewhere down deep in the Jasmine stack while processing the done()
call, i.e., not anywhere in my code. The failure is apparently in the jasmine dispatch() method, i.e., here:function dispatch(method, args) {
for (var i = 0; i < reporters.length; i++) {
var reporter = reporters[i];
if (reporter[method]) {
reporter[method].apply(reporter, args); // <-- THIS IS WHERE IT FAILS
}
}
}
Normally I would troubleshoot these test failures in the browser's dev console. But they don't fail there, even on my build machine - they only fail when running via Chutzpah, and then only on my build machine. (And, I should note, very occasionally, the tests do run correctly, which points to some sort of timing error, but darned if I know what it is.)Any suggestions for troubleshooting this?