How do I tell Mocha to only run a certain test in the browser (and not in node.js)?

I’m using Mocha to test modules in my javascript application. One of my modules depends on there being a document object, so the test for that module fails when I run my tests in node.js and passes in the testing page in the browser.

How can I tell Mocha to only run this specific test in the browser and not in node.js?

if(window && window.document){ runBrowserOnlyTests(); } //?

Oops. Forgot to check for existence of window first. Sorry I didn't catch that. You could just check for 'document' globally but explicit seems best in this case as document or window could easily be some other var in Node. If somebody defined an object named window in Node with a document property, well, that's just ignorant. Although I suppose you could then check constructor names if you were worried about that but this strikes me as sufficient, especially since I assume node modules each have their own global objects or their wouldn't be much point to the require method. (somebody correct me if I'm wrong)