Skip to content

Fix misspelled moduleNameMapper key in jest.config.js#2

Closed
ruanbarroso wants to merge 1 commit into
mainfrom
fix/jest-config-modulenamemapper
Closed

Fix misspelled moduleNameMapper key in jest.config.js#2
ruanbarroso wants to merge 1 commit into
mainfrom
fix/jest-config-modulenamemapper

Conversation

@ruanbarroso

Copy link
Copy Markdown
Owner

Summary

jest.config.js defined the module alias under the key moduleNameMapping, which is not a valid Jest option. On every test run Jest printed:

Validation Warning: Unknown option "moduleNameMapping" was found.
This means your test cases might not behave as expected.

Because the key was invalid, the hand-written mapping was silently dropped:

moduleNameMapping: {            // ❌ ignored by Jest
  '^@/(.*)$': '<rootDir>/src/$1',
},

The @/ import alias kept working only by accident — next/jest injects its own moduleNameMapper derived from tsconfig paths, so the dead entry was never actually needed.

This PR renames the key to the correct moduleNameMapper, so the entry is valid and merges with the mapper next/jest generates.

Verification

  • npm test now runs with no validation warning.
  • All tests pass (Test Suites: 1 passed, Tests: 3 passed).

🤖 Generated with Claude Code

The custom Jest config used `moduleNameMapping`, which is not a valid Jest
option, producing on every run: Validation Warning: Unknown option
"moduleNameMapping" was found. This means your test cases might not behave
as expected.

The hand-written `^@/(.*)$` -> `<rootDir>/src/$1` mapping was silently
ignored; the `@/` alias only resolved because next/jest injects its own
moduleNameMapper derived from tsconfig paths. Renaming the key to the
correct `moduleNameMapper` makes the entry valid and lets it merge with
next/jest's generated mapper.

Verified: `npm test` runs with no validation warning and all tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ruanbarroso ruanbarroso closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant