Writing some helper functions to use phantomJs as our testing framework, is there any way to make ‘void’ functions… or to make phantomJs ignore the return value somehow?
var mod = require('./mymod.js');
mod.doStuff();
>> TypeError: 'undefined' is not a function
For convenience sake, is there any way to accomplish this? or a good reason why i shouldn’t?
the method exists fine. it’s just a method that triggers something. So there’s nothing in the design the merits a return value for it.
if I do var ignore = mod.doStuff(); all is fine. But as I said, for convenience…
i think it tries to evaluate all statements. maybe i’m just used to the lazy parsers that ignore data types on the execution level.
It is impossible that
mod.doStuff()would generate an error whenvar ignore=mod.doStuff();does not. There is some other problem, which maybe could be tracked down if you’d post your entire code. Start with the basics: put a breakpoint at the line in question, and when it stops there, examine the value of mod.doStuff and make sure it’s a function, etc. etc. In order to do this with phantomJS, google for “phantomJS remote debugging”, which will tell you about the--remote-debugger-portoption, so you can open a web browser tohttp://localhost:portand debug using standard approach.