---
title: "test"
description: "使用 test/ 目录来组织应用程序的单元测试、Nuxt 测试和端到端测试。"
canonical_url: "https://nuxt.zhcndoc.com/docs/4.x/directory-structure/test"
---
# test

> 使用 test/ 目录来组织应用程序的单元测试、Nuxt 测试和端到端测试。

`test/` 目录是存放应用程序测试的推荐位置。Nuxt 不会像扫描 `app/` 或 `server/` 那样扫描此目录；你可以自行选择测试运行器和目录布局（通常使用 [`@nuxt/test-utils`](https://nuxt.zhcndoc.com/docs/4.x/getting-started/testing)）。

一种常见的目录结构是按环境进行划分：

```bash [目录结构]
-| test/
---| e2e/
---| nuxt/
---| unit/
```

- `test/unit/` — 不使用 Nuxt 运行时的快速 Node 测试
- `test/nuxt/` — 需要 Nuxt 运行时环境的测试
- `test/e2e/` — 针对运行中应用的端到端测试

::read-more{to="https://nuxt.zhcndoc.com/docs/4.x/getting-started/testing#organizing-your-tests"}
有关设置、Vitest 项目和 TypeScript 上下文的信息，请参阅 **组织测试**。
::


## Sitemap

See the full [sitemap](https://nuxt.zhcndoc.com/sitemap.md) for all pages.
