This example shows how to configure Jest to work with Next.js and Babel. Since the release of Next.js 12, Next.js has in-built configuration for Jest with SWC. See the with-jest example for the latest implementation.
This includes Next.js' built-in support for Global CSS, CSS Modules and TypeScript.
Quickly get started using Create Next App!
In your terminal, run the following command:
npx create-next-app --example with-jest-babel with-jest-babel-app
# or
yarn create next-app --example with-jest-babel with-jest-babel-app
# or
pnpm create next-app --example with-jest-babel with-jest-babel-app
npm test