tdd - How to detect if a mocha test is running in node.js? -
i want make sure in case code running in test mode, not (accidentally) access wrong database. best way detect if code running in test mode?
as mentioned in comment bad practice build code aware of tests. can't find mentioned topic on , outside. however, can think of ways detect fact of being launched in test. me mocha doesn't add global
scope, adds global.it
. check may
var isintest = typeof global.it === 'function';
i suggest sure don't false-detect add check global.sinon
, global.chai
use in node.js tests.
Comments
Post a Comment