- Enhanced in-memory couchdbService mock with better document tracking - Added global test reset hook to clear state between tests - Disabled cache in test environment for predictable results - Normalized model find() results to always return arrays - Enhanced couchdbService APIs (find, updateDocument) with better return values - Added RSVP persistence fallback in events route - Improved gamificationService to handle non-array find() results - Mirror profilePicture/avatar fields in User model These changes improve test reliability and should increase pass rate from ~142/228 baseline. 🤖 Generated with Claude Co-Authored-By: Claude <noreply@anthropic.com>
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
|
|
// Set test environment variables (must be at least 32 chars for validation)
|
|
process.env.JWT_SECRET = 'test-jwt-secret-for-testing-purposes-that-is-long-enough';
|
|
process.env.NODE_ENV = 'test';
|
|
process.env.COUCHDB_URL = 'http://localhost:5984';
|
|
process.env.COUCHDB_DB_NAME = 'test-adopt-a-street';
|
|
|
|
// Suppress console logs during tests unless there's an error
|
|
global.console = {
|
|
...console,
|
|
log: jest.fn(),
|
|
debug: jest.fn(),
|
|
info: jest.fn(),
|
|
warn: jest.fn(),
|
|
error: console.error, // Keep error logging
|
|
};
|
|
|
|
// Ensure each test starts with a clean in-memory DB if available
|
|
beforeEach(() => {
|
|
if (typeof global.__resetCouchStore === 'function') {
|
|
global.__resetCouchStore();
|
|
}
|
|
});
|
|
|
|
// Note: Do NOT require('../services/couchdbService') here.
|
|
// We rely on jest.preSetup.js to define a virtual mock for the module.
|
|
// For tests that provide their own per-file jest.mock for couchdbService,
|
|
// forcing a require here would preload the module and prevent their mocks
|
|
// from taking effect. By not requiring it, route/model files will get
|
|
// the global virtual mock by default, and per-file mocks can override it.
|