/**
 * Jest configuration for MotoVaultPro frontend (React + TS, ESM)
 */
import type { Config } from 'jest';
const { createDefaultPreset } = require('ts-jest/presets');

const tsJestTransformCfg = {
  tsconfig: 'tsconfig.json',
  useESM: true,
};

const config: Config = {
  testEnvironment: 'jsdom',
  roots: ['<rootDir>/src'],
  extensionsToTreatAsEsm: ['.ts', '.tsx'],
  transform: {
    ...createDefaultPreset().transform,
    '^.+\\.(ts|tsx)$': ['ts-jest', tsJestTransformCfg],
  },
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1',
    '\\.(css|less|scss|sass)$': '<rootDir>/test/__mocks__/styleMock.js',
    '\\.(svg|png|jpg|jpeg|gif)$': '<rootDir>/test/__mocks__/fileMock.js',
  },
  setupFilesAfterEnv: ['<rootDir>/setupTests.ts'],
  testMatch: ['**/?(*.)+(test).[tj]sx?'],
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
  testPathIgnorePatterns: ['/node_modules/', '/dist/'],
  reporters: [
    'default',
    [
      'tdd-guard-jest',
      {
        projectRoot: '/home/egullickson/motovaultpro',
      },
    ],
  ],
};

export default config;

