import type { Config } from "jest";
import nextJest from "next/jest.js";

// Point Next's Jest transformer at the app root so next.config + .env + SWC
// transforms (TS/JSX, path aliases) are wired up automatically.
const createJestConfig = nextJest({ dir: "./" });

const config: Config = {
  testEnvironment: "jest-environment-jsdom",
  setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
  // Resolve the `@/*` path alias from tsconfig.
  moduleNameMapper: {
    "^@/(.*)$": "<rootDir>/src/$1",
  },
  testMatch: ["<rootDir>/src/**/*.test.ts", "<rootDir>/src/**/*.test.tsx"],
  // Only the pure helper modules are meaningful to cover; 3D/canvas/scroll
  // components are excluded from coverage (untestable under jsdom).
  collectCoverageFrom: [
    "src/components/strategy/theme.ts",
    "src/components/optimization/math.ts",
    "src/components/optimization/constants.ts",
    "src/components/logisticsbrain/math.ts",
  ],
};

export default createJestConfig(config);
