- Add jest.config.js with test environment configuration
- Add tests/setup.js to load .env.test before tests
- Add tests/helpers/cleanup.js for test data cleanup utilities
- Add scripts/clean-test-db.js for manual test database cleanup
- Fix ObjectId constructor calls in api.admin.test.js (must use 'new')
- Add .env.test for test-specific configuration
- Use tractatus_prod database for tests (staging environment)
Test Results:
- Before: 29 failing tests (4 test suites)
- After: 13 failing tests (4 test suites)
- Progress: 16 test failures fixed (55% improvement)
Remaining Issues:
- 4 auth test failures (user creation/password mismatch)
- 4 documents test failures (duplicate keys)
- 2 admin moderation test failures
- 3 health check test failures (response structure)
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
40 lines
685 B
JavaScript
40 lines
685 B
JavaScript
/**
|
|
* Jest Configuration
|
|
*/
|
|
|
|
module.exports = {
|
|
// Test environment
|
|
testEnvironment: 'node',
|
|
|
|
// Setup files to run before tests
|
|
setupFiles: ['<rootDir>/tests/setup.js'],
|
|
|
|
// Coverage configuration
|
|
collectCoverageFrom: [
|
|
'src/**/*.js',
|
|
'!src/server.js',
|
|
'!**/node_modules/**',
|
|
'!**/tests/**'
|
|
],
|
|
|
|
// Coverage thresholds (aspirational)
|
|
coverageThresholds: {
|
|
global: {
|
|
branches: 40,
|
|
functions: 35,
|
|
lines: 45,
|
|
statements: 45
|
|
}
|
|
},
|
|
|
|
// Test match patterns
|
|
testMatch: [
|
|
'**/tests/**/*.test.js'
|
|
],
|
|
|
|
// Verbose output
|
|
verbose: true,
|
|
|
|
// Test timeout (increased for integration tests)
|
|
testTimeout: 10000
|
|
};
|