fix(tests): make NODE_ENV=test check a hard failure (GAP-SYNC-046)

Change from warning to process.exit(1) to prevent any possibility of
running destructive test operations against a production database.

Tests now fail immediately if NODE_ENV !== 'test', with clear instructions
on how to fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Ben West
2026-03-12 12:39:01 -07:00
co-authored by Copilot
parent 61501cac3a
commit e12cf3d2e2
+4 -3
View File
@@ -4,10 +4,11 @@ var testHelpers = require('./lib/test-helpers');
// GAP-SYNC-046: Safety check to prevent tests running against production
if (process.env.NODE_ENV !== 'test') {
console.error('\n⚠️ SAFETY WARNING: NODE_ENV is not "test" (current: ' + (process.env.NODE_ENV || '(not set)') + ')');
console.error('\n SAFETY ERROR: NODE_ENV must be "test" to run tests.');
console.error(' Current value: ' + (process.env.NODE_ENV || '(not set)'));
console.error(' Tests use deleteMany({}) which could destroy production data.');
console.error(' Set NODE_ENV=test in your test environment.\n');
// Allow tests to continue with warning, but guarded operations will fail
console.error(' Fix: Use "npm test" which loads my.test.env, or set NODE_ENV=test\n');
process.exit(1);
}
var slowTestThreshold = parseInt(process.env.SLOW_TEST_THRESHOLD, 10) || 2000;