Assuming you're testing javascript that is intended to run in node 
(javascript with require()s in it), you should run the tests in node, not 
the browser. That said, it's possible to "browserify" your node javascript 
to get it to run in the browser, but it's better and simpler to test node 
javascript in node itself.

Some of the most popular browser-based test frameworks (qunit & jasmine) 
have node-based runners (jasmine-node and node-qunit). Or you could use a 
test framework that is more node-focused (like mocha or vows).

If you're writing cross-platform code that needs to run both in node and in 
the browser, you should run the tests in both environments to verify that 
both work as expected (personally I write mocha tests and use both their 
html reporter (browser) and their default "Dot Matrix" reporter (node)).

Aside: if you're interested in writing code that runs in both the browser 
and node, you can use browserify, which a lot of the people on this list 
use, or you can use a little boilerplate in your libraries (as the backbone 
& underscore libraries do) -- I wrote a little bit about this 
here: http://csnw.github.io/2013/06/23/this-in-node-modules-and-iifes.html.

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/2580dd07-2a35-43f2-9819-1d2f5726ecbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to