the-tip-top-backend/jest.config.js
soufiane 74a7f387c5 fix: resolve test failures in CI pipeline
- Add jest.setup.js with JWT_SECRET for test environment
- Update jest.config.js with setupFiles and increased timeout
- Fix auth middleware to return 401 (not 403) for invalid JWT tokens
- Fix errorHandler to return 'message' instead of 'error' in response
- Fix validate middleware to properly detect Zod errors in ESM
- Remove unused 'pool' import in middleware tests (lint fix)
- Update middleware tests to check next() calls with AppError

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 12:05:00 +01:00

41 lines
743 B
JavaScript

export default {
// Use Node's experimental ESM support
testEnvironment: 'node',
// Setup files to run before tests
setupFiles: ['./jest.setup.js'],
// Transform ES modules
transform: {},
// Module name mapper for ES modules
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
// Test match patterns
testMatch: [
'**/test/**/*.test.js',
'**/__tests__/**/*.js',
],
// Coverage configuration
collectCoverageFrom: [
'src/**/*.js',
'!src/**/*.test.js',
'!**/node_modules/**',
],
// Ignore patterns
testPathIgnorePatterns: [
'/node_modules/',
'/dist/',
],
// Verbose output
verbose: true,
// Test timeout (increase for database operations)
testTimeout: 10000,
};