Comment

Comment by FooBarWidget

I'm writing a server in Node and to date I'm still trying to figure out how to control the main loop from Node. I want to write tests like this:

    1. register some timers and create some sockets
    2. send some stuff over the sockets
    3. wait until the socket handlers received some data which cause the handlers to unregister the sockets and timers
    4. at this point, the main event loop has ended. go to next test and setup a new event loop
How do you do (3) and (4) in Node? I have no idea, and I couldn't find any clear answers on the Internet. I ended up writing my tests in RSpec which launch Node processes, and I just check whether the stuff printed to stdout matches what I expect. RSpec also happens to have a much much nicer syntax than any Javascript testing framework I've encountered.
parent FooBarWidget 14 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton