> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards.md).

# 测试标准

本节描述了在 Decentraland 各项目中的不同服务和 UI 中如何进行测试。

本文档中的关键词“MUST”“MUST NOT”“REQUIRED”“SHALL”“SHALL NOT”“SHOULD”“SHOULD NOT”“RECOMMENDED”“MAY”和“OPTIONAL”应按……中的描述进行解释 [RFC 2119](https://datatracker.ietf.org/doc/html/rfc2119).

## 概览

测试是我们开发流程中的关键部分。我们在所有项目中都对测试覆盖率和质量保持高标准。本文档为以下内容提供全面指南：

* [**编写测试**](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/writing-tests.md) - 编写可维护、清晰测试的一般原则和模式
* [**测试 UI**](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/testing-uis.md) - 测试 React 组件、Redux sagas、reducer、selector 和 action creator
* [**测试服务（众所周知组件）**](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/testing-services-wkc.md) - 测试基于 well-known-component 架构构建的模块化服务
* [**测试服务（已弃用）**](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/testing-services-deprecated.md) - 测试服务的旧方法（供参考）
* [**端到端测试**](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/testing-e2e.md) - 使用 Cypress 进行 E2E 测试（进行中）

## 测试理念

我们的测试方法强调：

* **清晰性** - 测试应当具有自说明性且易于理解
* **可维护性** - 当需求变化时，测试应当易于更新
* **隔离性** - 每个测试都应独立运行，且不影响其他测试
* **覆盖率** - 所有关键路径和边界情况都应被测试
* **值** - 测试应能让人相信代码按预期工作

## 快速链接

* [如何使用……来描述上下文 `describe`](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/writing-tests.md#describing-and-building-context)
* [如何使用……来编写期望 `它`](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/writing-tests.md#describing-expectations-and-executing-code)
* [测试什么以及何时测试](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/writing-tests.md#what-to-test)
* [何时以及如何进行 mock](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards/writing-tests.md#when-to-mock)

## 相关标准

* [依赖管理](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/dependency-management.md) - 管理 npm 依赖和 peerDependencies
* [UI 标准](https://github.com/decentraland/docs/tree/main/contributor/contributor-guides/ui-standards/README.md) - Redux 和 RTK Query 模式
* [API 文档](/contributor/contributor-zh/gong-xian-zhe-zhi-nan/api-documentation.md) - OpenAPI 文档标准


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/contributor/contributor-zh/gong-xian-zhe-zhi-nan/testing-standards.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
