Some checks failed
CI/CD Pipeline / Quick Checks (pull_request) Failing after 9s
CI/CD Pipeline / ESLint (pull_request) Has been skipped
CI/CD Pipeline / Test & Coverage (pull_request) Has been skipped
CI/CD Pipeline / Build Application (pull_request) Has been skipped
CI/CD Pipeline / Security Audit (pull_request) Has been skipped
53 lines
1.8 KiB
JavaScript
53 lines
1.8 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
|
|
dir: './',
|
|
});
|
|
|
|
// Add any custom config to be passed to Jest
|
|
const customJestConfig = {
|
|
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
|
testEnvironment: 'jsdom',
|
|
moduleNameMapper: {
|
|
'^@/(.*)$': '<rootDir>/src/$1',
|
|
'^@/components/(.*)$': '<rootDir>/src/components/$1',
|
|
'^@/lib/(.*)$': '<rootDir>/src/lib/$1',
|
|
'^@/utils/(.*)$': '<rootDir>/src/utils/$1',
|
|
'^@/hooks/(.*)$': '<rootDir>/src/hooks/$1',
|
|
'^@/types/(.*)$': '<rootDir>/src/types/$1',
|
|
},
|
|
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts', '!src/**/index.ts'],
|
|
coverageThreshold: {
|
|
global: {
|
|
branches: 70,
|
|
functions: 70,
|
|
lines: 70,
|
|
statements: 70,
|
|
},
|
|
},
|
|
testMatch: ['**/__tests__/**/*.(js|jsx|ts|tsx)', '**/*.(test|spec).(js|jsx|ts|tsx)'],
|
|
testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/', '<rootDir>/e2e/'],
|
|
transform: {
|
|
'^.+\\.(js|jsx|ts|tsx)$': ['babel-jest', { presets: ['next/babel'] }],
|
|
},
|
|
transformIgnorePatterns: ['/node_modules/', '^.+\\.module\\.(css|sass|scss)$'],
|
|
// Performance optimizations
|
|
maxWorkers: '50%',
|
|
cache: true,
|
|
cacheDirectory: '.jest-cache',
|
|
clearMocks: true,
|
|
collectCoverage: false, // Only collect coverage when explicitly requested
|
|
coverageReporters: ['text', 'lcov'],
|
|
errorOnDeprecated: true,
|
|
// Reduce memory usage
|
|
logHeapUsage: true,
|
|
// Faster test discovery
|
|
testLocationInResults: true,
|
|
// Skip coverage for faster runs in watch mode
|
|
watchPathIgnorePatterns: ['<rootDir>/coverage/', '<rootDir>/.next/'],
|
|
};
|
|
|
|
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
|
|
module.exports = createJestConfig(customJestConfig);
|