I'm struggling to understand config files and encountering issues while attempting to run jest unit tests:
Cannot locate module '@/app/utils/regex' from 'src/_components/DriverSearchForm.tsx'
Here's my jest configuration:
import type { Config } from 'jest'
import nextJest from 'next/jest.js'
const createJestConfig = nextJest({
dir: './',
})
const config: Config = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
moduleDirectories: ['node_modules', '<rootDir>/src'],
moduleNameMapper: {
'^@/_components/(.*)': '<rootDir>/src/_components/$1',
},
testEnvironment: 'jsdom',
preset: 'ts-jest',
transform: {
'^.+\\.(js|jsx|ts|tsx|mjs)$': ['ts-jest', { tsconfig: 'tsconfig.test.json' }],
},
}
export default createJestConfig(config)