Back to Next Js

Next.js + Jest

examples/with-jest-babel/README.md

16.2.51.1 KB
Original Source

Next.js + Jest

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.

How to Use

Execute create-next-app with npm, Yarn, or pnpm to bootstrap the example:

bash
npx create-next-app --example with-jest-babel with-jest-babel-app
bash
yarn create next-app --example with-jest-babel with-jest-babel-app
bash
pnpm create next-app --example with-jest-babel with-jest-babel-app

Run Jest Tests

bash
npm test
bash
yarn test
bash
pnpm test

Deploy it to the cloud with Vercel (Documentation).