Fix jwt-token
This commit is contained in:
@@ -1,5 +1,21 @@
|
||||
// IMPORTANT: Set environment variables FIRST, before any other imports
|
||||
process.env.NODE_ENV = 'test';
|
||||
proces // Return test context
|
||||
models = {
|
||||
sequelize,
|
||||
Device,
|
||||
DroneDetection,
|
||||
Heartbeat,
|
||||
User,
|
||||
AlertRule,
|
||||
AlertLog,
|
||||
Tenant,
|
||||
ManagementUser
|
||||
};
|
||||
|
||||
// Store models globally so routes can access them
|
||||
global.__TEST_MODELS__ = models;
|
||||
|
||||
return { sequelize, models };est';
|
||||
process.env.JWT_SECRET = 'test-jwt-secret-key-for-testing-only';
|
||||
process.env.DATABASE_URL = ':memory:';
|
||||
process.env.DB_DIALECT = 'sqlite';
|
||||
@@ -20,7 +36,7 @@ afterEach(() => {
|
||||
// Test database configuration
|
||||
const testDatabase = {
|
||||
dialect: 'sqlite',
|
||||
storage: './test.db', // Use same file database as models/index.js
|
||||
storage: ':memory:', // In-memory database for fast tests
|
||||
logging: false, // Disable SQL logging in tests
|
||||
sync: { force: true } // Always recreate tables for tests
|
||||
};
|
||||
@@ -32,6 +48,9 @@ let models;
|
||||
* Setup test environment before all tests
|
||||
*/
|
||||
async function setupTestEnvironment() {
|
||||
// Clear any existing global models
|
||||
delete global.__TEST_MODELS__;
|
||||
|
||||
// Create test database connection
|
||||
sequelize = new Sequelize(testDatabase);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user