diff --git a/services/web/app/src/infrastructure/mongojs.js b/services/web/app/src/infrastructure/mongojs.js index e3a1e5ae49..88d540e2b7 100644 --- a/services/web/app/src/infrastructure/mongojs.js +++ b/services/web/app/src/infrastructure/mongojs.js @@ -5,6 +5,16 @@ // Fix any style issues and re-enable lint. const Settings = require('settings-sharelatex') const mongojs = require('mongojs') + +if ( + typeof global.beforeEach === 'function' && + process.argv.join(' ').match(/unit/) +) { + throw new Error( + 'It looks like unit tests are running, but you are connecting to Mongo. Missing a stub?' + ) +} + const db = mongojs(Settings.mongo.url, [ 'projects', 'users', diff --git a/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js b/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js index 82708a533d..31bcba6ce0 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js @@ -110,6 +110,7 @@ describe('SubscriptionUpdater', function() { warn() {} }, 'settings-sharelatex': this.Settings, + '../../infrastructure/mongojs': { db: {}, ObjectId }, './FeaturesUpdater': this.FeaturesUpdater, '../../models/DeletedSubscription': { DeletedSubscription: this.DeletedSubscription