Why no assert module?

24 views
Skip to first unread message

martypdx

unread,
Feb 13, 2011, 9:29:00 PM2/13/11
to JSApp.US
For my 'quick, weekend hack like projects' i still like to TDD.

Matthew Francis-Landau

unread,
Feb 14, 2011, 12:29:34 PM2/14/11
to jsap...@googlegroups.com
The thing about the assert module, is that there is not a great way to get the data back out to the developer.  I am somewhat trying to avoid having your users of your programs get your random debug info.  Also There is no good way in the current system to track what request is currently getting processed by an application, and thus where to get the error back to.

One possible way to accomplish the assert module, would be to have it throw an error when there is a problem; node-host attempts to catch errors and display them to the user, but if it is unable to figure out where the error should be going, then it simply drops it (you code is halted at this point, and your connection is not necessarily closed).

If you have some ideas on how to get around this, with out too much over head, you are welcome to voice them or contribuite them to node-host.  Otherwise for the time being I have opened an issue: https://github.com/matthewfl/node-host/issues/issue/13


On Sun, Feb 13, 2011 at 6:29 PM, martypdx <marty....@yahoo.com> wrote:
For my 'quick, weekend hack like projects' i still like to TDD.

Martin Nelson

unread,
Feb 14, 2011, 8:39:01 PM2/14/11
to jsap...@googlegroups.com
Good point, I made the mistake of asking for an implementation rather than talking about what I want to achieve. I don't want the assert module, I just want a tdd framework available.

I got around it initially by just creating my own tests and runner and outputting that:

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end(runTests());
}).listen();

function runTests() {

}

But I mostly didn't want to do my own testing framework.  I'm new to node, seems like Vows is popular, but there are several other candidates as well.

I think the trick is just to have an easy way to handle unit testing. If picking one enabled it to be baked in somehow (ctrl-t) that would be great.  I'll noddle on it a bit and see what I can come up with.

More than happy to contribute, I've just come from the dark side of 15 years of Microsoft development so I'm still figuring out the landscape. :)
Reply all
Reply to author
Forward
0 new messages