I have jasmine test spec file and I want to run it using both node.js and in browser. How can I detect if script is running in node?
A couple of ideas:
You can check for the window global object, if it is available then you are in a browser
if (typeof window === 'undefined')
// this is node
Or you can check for the process object, if it is available then you are in node
if(typeof process === 'object')
// this is also node
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments