// Synchronous mock for next/dynamic — resolves modules immediately in test env function dynamic(importFn, _options) { let Component = null; // Call the import function to get the promise, then extract synchronously // In tests modules are already loaded, so we can do a trick: // Return a wrapper that calls the import lazily on first render const Wrapper = (props) => { if (!Component) { throw new Error( 'next/dynamic mock: module not yet resolved. Use jest.mock for the specific module instead.', ); } const React = require('react'); return React.createElement(Component, props); }; // Resolve immediately (modules are synchronous in jest) importFn().then((mod) => { Component = mod.default || mod; }); return Wrapper; } module.exports = dynamic; module.exports.default = dynamic;