As per #160, it is technically possible to run code with the environment set to test even if the code isn't actually being run by Mocha. This causes a reference error for code which attempts to use after.
While that isn't the way the codebase is intended to be used, one possible way of making the code more robust is to use capability sniffing:
-if (process.env.NODE_ENV === 'test') {
+if (typeof global.after === 'function') {
after(...)
}
I'm not 100% sure I prefer this – it is safer, but perhaps less clear.