4 ms·
Thanks for the info. Next question for you (since I know you use a lot of Node.js). What's the recommended approaches for unit-testing your Node apps (Socket.IO
by hello_moto 15y ago
Thanks for the info. Next question for you (since I know you use a lot of Node.js). What's the recommended approaches for unit-testing your Node apps (Socket.IO, ExpressJS, whichever)?
What about switching between PROD, DEV, TEST environment like Rails? I found that feature is great since y'know... those environments will have different settings (I'm guessing the answer to this one is to roll your own kind of thing?)
- pkrumins 15y agoAbout unit testing - I like expresso [1], but recently also started using tap [2]. [1]: https://github.com/visionmedia/expresso https://github.com/visionmedia/expresso [2]: https://github.com/isaacs/node-tap https://github.com/isaacs/node-tap Also see my startup that does javascript unit testing in all the browsers: http://www.testling.com http://www.testling.com Now about switching environments, see this: http://expressjs.com/guide.html#configuration http://expressjs.com/guide.html#configuration And also see bouncy to route between production/development dynamically: https://github.com/substack/bouncy https://github.com/substack/bouncy
- funthree 15y agoThere are a number of ways to do this but when I first started with node I started by using some different files which hold environment variables. You can then export some environment variables based on where you are running your code (production, dev, staging, etc) For instance you might have a .production file export NODE_ENV="production" export NODE_PORT="80" And a .development file export NODE_ENV="development" export NODE_PORT="3000" Before you run "node app" just link to your variables with "$ . .production" or "$ sh .production" Again there are many ways to accomplish this same thing but this way is pretty straightforward if you are familiar with linux. EDIT: To add to the link to configuration pkrumins posted (http://expressjs.com/guide.html#configuration http://expressjs.com/guide.html#configuration) process.env will hold all of your environment variables, and express.js will read "NODE_ENV" internally. A combination of the above, and setting up corresponding internal configuration in your node.js app will provide for a very clean setup.