Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Vitest: Support for import aliases when using TypeScript #72430

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions docs/01-app/02-building-your-application/08-testing/01-vitest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,22 @@ npx create-next-app@latest --example with-vitest with-vitest-app

To manually set up Vitest, install `vitest` and the following packages as dev dependencies:

```bash filename="Terminal"
```bash filename="Terminal" switcher
# Using TypeScript
npm install -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom vite-tsconfig-paths
# Using JavaScript
npm install -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom
# or
yarn add -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom
# or
pnpm install -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom
# or
bun add -D vitest @vitejs/plugin-react jsdom @testing-library/react @testing-library/dom
```

Create a `vitest.config.ts|js` file in the root of your project, and add the following options:
Create a `vitest.config.mts|js` file in the root of your project, and add the following options:

```ts filename="vitest.config.ts" switcher
```ts filename="vitest.config.mts" switcher
import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
plugins: [react()],
plugins: [tsconfigPaths(), react()],
test: {
environment: 'jsdom',
},
Expand Down
Loading