AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Jest Manual Mocks Stopped Working In Next.Js 13.2.4

Manual mocks in Jest are no longer resolved automatically after upgrading to Next.js 13.2.4; the next/jest preset appears to have broken Jest's default __mocks__ lookup.

highConfidence 75%Next.jsHydrationApp RouterRoute HandlersAffected V13.2.4Affected V13.2.5-Canary.32

Origin Analysis

Changes introduced in next/jest (likely PR #45815) altered module resolution, preventing Jest from automatically detecting __mocks__ directories for both node_modules and local modules.
1. Clone https://github.com/adam187/with-jest-app/tree/not-mocked 2. yarn install 3. yarn test Observe that the useTest hook is not mocked despite a __mocks__ folder being present at the root.

Fixing Code Block

Edge Case Audit

This workaround requires manually listing every mocked module, which becomes unmaintainable with many mocks. It only works for absolute module specifiers, not relative imports. Downgrading to Next.js 13.2.3 is a safer interim solution. To roll back this hotfix, remove the moduleNameMapper entry and restore the previous jest config.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state