import type { Config } from "@jest/types"; const config: Config.InitialOptions = { preset: "ts-jest", testEnvironment: "jsdom", roots: ["/src", "/tests"], testMatch: ["**/__tests__/**/*.+(ts|tsx|js)", "**/?(*.)+(spec|test).+(ts|tsx|js)"], transform: { "^.+\\.(ts|tsx)$": "ts-jest", "^.+\\.(js|jsx)$": "babel-jest", // optional — اگر babel ندارید می‌توانید حذف کنید }, moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json"], moduleNameMapper: { "^@/(.*)$": "/src/$1", "^@public/lotties/(.*)$": "/public/lotties/$1", "^@package.json$": "/package.json", // "^@appointment/(.*)$": "/src/apps/appointment/$1", // "^@card/(.*)$": "/src/apps/card/$1", "^@new-ui/(.*)$": "/src/apps/new-ui/$1", // "^@new-ui-card/(.*)$": "/src/apps/new-ui-card/$1", // static assets & styles "^.+\\.(css|scss|sass)$": "/tests/__mocks__/styleMock.js", "^.+\\.(jpg|jpeg|png|gif|webp|svg)$": "/tests/__mocks__/fileMock.js", }, setupFiles: ["/tests/jestSetupFiles.ts"], // اجرا قبل از env setupFilesAfterEnv: ["/tests/setupTests.ts"], // اجرا بعد از env moduleDirectories: ["node_modules", "src"], testPathIgnorePatterns: ["/node_modules/", "/dist/", "/build/"], transformIgnorePatterns: ["/node_modules/(?!(some-esm-package)/)"], // اگر نیاز به transpile node_modules دارید آن‌ها را لیست کنید collectCoverage: false, globals: { "ts-jest": { tsconfig: "tsconfig.jest.json", // اگر فایل جدا دارید؛ در غیر این‌صورت 'tsconfig.json' }, }, }; export default config;