Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added __test__/inputField.test.tsx
Empty file.
40 changes: 40 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { Config } from "jest";
import nextJest from "next/jest.js";

const createJestConfig = nextJest({
dir: "./",
});

const config: Config = {
coverageProvider: "v8",
testEnvironment: "jsdom",
clearMocks: true,
collectCoverage: true,
coverageDirectory: "coverage",
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
collectCoverageFrom: [
"**/*.{js,jsx,ts,tsx}",
"!**/*.d.ts",
"!**/node_modules/**",
"!**/.next/**",
"!**/out/**",
"!**/build/**",
"!**/next-env.d.ts",
"!**/jest.config.ts",
"!**/jest.setup.ts",
"!**/__test__/**",
"!**/coverage/**",
"!**/public/**",
"!**/next.config.ts",
"!**/app/layout.tsx",
"!**/app/**",
"!**/types/**",
],

moduleNameMapper: {
// ...
"^@/components/(.*)$": "<rootDir>/components/$1",
},
Comment on lines +34 to +37
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Incomplete module alias mapping.

The moduleNameMapper only maps @/components/*, but tsconfig.json defines @/* to map to the entire project root. This will cause resolution failures for imports like @/lib/*, @/utils/*, @/hooks/*, etc.

🔧 Suggested fix
  moduleNameMapper: {
-   // ...
-   "^@/components/(.*)$": "<rootDir>/components/$1",
+   "^@/(.*)$": "<rootDir>/$1",
  },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
moduleNameMapper: {
// ...
"^@/components/(.*)$": "<rootDir>/components/$1",
},
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/$1",
},
🤖 Prompt for AI Agents
In `@jest.config.ts` around lines 34 - 37, The moduleNameMapper currently only
maps "@/components/(.*)" which misses the project-wide "@/..." alias; update
moduleNameMapper to include a catch-all mapping for the "@/..." alias (e.g., add
a mapping for "^@/(.*)$" -> "<rootDir>/$1") so imports like "@/lib/*",
"@/utils/*", "@/hooks/*" resolve correctly, leaving the existing
"@/components/(.*)" mapping intact if desired.

};

export default createJestConfig(config);
1 change: 1 addition & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "@testing-library/jest-dom";
Loading