hosting-frontend/jest.config.js
Alexis Bruneteau 33272327d8 fix(tests): fix CI test failures - improve test helpers and configuration
## Changes
- Updated jest.config.js to exclude utility test files from test execution
- Enhanced test-helpers with flexible auth context mocking
- Support for authenticated and unauthenticated test states
- Fixed landing page tests to use unauthenticated state
- Fixed navbar tests to handle multiple identical elements
- Fixed portfolio dashboard tests for status indicators
- Improved .gitignore with .env file exclusions

## Test Status
- Passing: 310/338 tests (92%)
- Failing: 28 tests (8%)
- Main issues: Multiple element matching, async validation

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 23:34:21 +02:00

56 lines
1.4 KiB
JavaScript

const nextJest = require('next/jest')
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
})
// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv: ['<rootDir>/__tests__/setup.ts'],
testEnvironment: 'jest-environment-jsdom',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
},
collectCoverageFrom: [
'app/**/*.{ts,tsx}',
'components/**/*.{ts,tsx}',
'hooks/**/*.{ts,tsx}',
'lib/**/*.{ts,tsx}',
'!**/*.d.ts',
'!**/node_modules/**',
'!**/.next/**',
'!**/coverage/**',
'!**/jest.config.js',
],
coverageThreshold: {
global: {
branches: 90,
functions: 90,
lines: 90,
statements: 90,
},
},
testMatch: [
'**/__tests__/**/*.test.{ts,tsx}',
'**/*.test.{ts,tsx}',
],
testPathIgnorePatterns: [
'<rootDir>/.next/',
'<rootDir>/node_modules/',
'<rootDir>/src/',
'<rootDir>/angular-backup/',
'<rootDir>/__tests__/setup.ts',
'<rootDir>/__tests__/mocks/',
'<rootDir>/__tests__/fixtures/',
'<rootDir>/__tests__/utils/',
],
transformIgnorePatterns: [
'/node_modules/',
'^.+\\.module\\.(css|sass|scss)$',
],
}
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)