I have config/index.js
which returns a different config file based on the NODE_ENV environment variable that is set.
I\'m trying to write a simple test
I would delete the module from Node's module cache before running the 2nd test:
var resolved = require.resolve(__dirname + '/../../config');
delete require.cache[resolved];
So when requiring it again, Node will load from scratch. Note that the code above will only delete the config
module from the cache. If you need to delete the modules loaded by the require
calls inside your config
module, then you'll have to do the same as above for each of them too.
By the way, if your tests are going to become asynchronous, the you need the done
callback like you currently have. If your tests are meant to remain synchronous as they are now, the you could remove done
from the argument list of the callbacks you give to it
and omit calling it.