diff --git a/server/tests/routes/detections.test.js b/server/tests/routes/detections.test.js index bbe4d51..ed93a03 100644 --- a/server/tests/routes/detections.test.js +++ b/server/tests/routes/detections.test.js @@ -4,11 +4,10 @@ const sinon = require('sinon'); const request = require('supertest'); const express = require('express'); const { setupTestEnvironment, teardownTestEnvironment, cleanDatabase, createTestUser, createTestTenant, createTestDevice, createTestDetection, generateTestToken } = require('../setup'); -const detectionsRoutes = require('../../routes/detections'); const { authenticateToken, setModels } = require('../../middleware/auth'); describe('Detections Routes', () => { - let app, models, sequelize; + let app, models, sequelize, detectionsRoutes; before(async () => { ({ models, sequelize } = await setupTestEnvironment()); @@ -17,6 +16,9 @@ describe('Detections Routes', () => { global.__TEST_MODELS__ = models; setModels(models); + // Require detections routes AFTER setting up global models + detectionsRoutes = require('../../routes/detections'); + // Setup express app for testing app = express(); app.use(express.json());