setup.js 771 B

1234567891011121314151617181920212223242526
  1. /**
  2. * Test setup: uses an in-memory SQLite database and a fixed JWT secret.
  3. * All test files require this module first via mocha --require.
  4. */
  5. // Override the config module before anything else loads it
  6. const Module = require('module');
  7. const originalLoad = Module._load;
  8. const testConfig = {
  9. port: 3099,
  10. database: { type: 'sqlite', storage: ':memory:' },
  11. jwt: { secret: 'test-secret', expiresIn: '1h' },
  12. upload: { maxFileSizeMB: 10, tempDir: './temp' },
  13. cors: { origin: '*' },
  14. };
  15. Module._load = function (request, parent, isMain) {
  16. if (request === '../config' || request === '../../config') {
  17. return testConfig;
  18. }
  19. return originalLoad.apply(this, arguments);
  20. };
  21. // Also expose the config globally for test files
  22. global.testConfig = testConfig;