Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

jest-next-dynamic-ts

DavidYang21498.7kMIT0.1.1TypeScript support: included

Jest & Next.js - Dynamic import with TypeScript

jest-next-dynamic-ts, dynamic import, jest, typescript

readme

jest-next-dynamic-ts

Inspired by jest-next-dynamic.

Added TypeScript based on jest-next-dynamic.

GitHub: jest-next-dynamic-ts
npm: jest-next-dynamic-ts

📚 Install dependencies

npm install -D jest-next-dynamic-ts

🧪 Usage

// This will mock `next/dynamic`, so make sure to import it before any of your
// components.
import preloadAll from "jest-next-dynamic-ts";
// This component can have dynamic imports anywhere in its rendered tree,
// including nested dynamic imports.
import SomeComponent from "./SomeComponent";

beforeAll(async () => {
  await preloadAll();
});

// Your tests here!