7a256e657b
Building off https://github.com/vercel/next.js/pull/54891, updates the `with-jest` and `with-vitest` examples with updated packages and App Router tests.
35 lines
1.4 KiB
Markdown
35 lines
1.4 KiB
Markdown
# Vitest
|
|
|
|
This example shows how to use [Vitest](https://github.com/vitest-dev/vitest) with Next.js.
|
|
|
|
This includes Next.js' built-in support for Global CSS, CSS Modules and TypeScript. This example also shows how to use Vitest with the App Router and React Server Components.
|
|
|
|
> **Note:** Since tests can be co-located alongside other files inside the App Router, we have placed those tests in `app/` to demonstrate this behavior (which is different than `pages/`). You can still place all tests in `__tests__` if you prefer.
|
|
|
|
## Deploy your own
|
|
|
|
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-vitest&project-name=with-vitest&repository-name=with-vitest)
|
|
|
|
## How to use
|
|
|
|
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:
|
|
|
|
```bash
|
|
npx create-next-app --example with-vitest with-vitest-app
|
|
```
|
|
|
|
```bash
|
|
yarn create next-app --example with-vitest with-vitest-app
|
|
```
|
|
|
|
```bash
|
|
pnpm create next-app --example with-vitest with-vitest-app
|
|
```
|
|
|
|
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
|
|
|
|
## Running Tests
|
|
|
|
```bash
|
|
npm test
|
|
```
|