> 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/testing-e2e.md).

# 端到端测试

{% hint style="info" %}
本节目前仍在进行中（WIP）。
{% endhint %}

本节描述开发者将如何测试与端到端（e2e）测试相关的代码库。

## 测试栈

我们所有的 UI 测试都必须使用 [Cypress](https://www.cypress.io/) 作为主要测试框架，并结合 [Synpress](https://github.com/Synthetixio/synpress) 用于钱包支持。测试代码必须使用 [TypeScript](https://www.typescriptlang.org/) 并使用 [ts-jest](https://github.com/kulshekhar/ts-jest) 以获得类型检查支持。

## 目录结构

新测试必须放置在 `tests/e2e` 目录中，位于根路径下。文件将以其所测试的流程命名，也就是说，如果 e2e 测试文件将测试 `集合发布` 流程，那么文件名必须为 `collection-publication.spec.cy.ts`.

## 运行频率

通过 GitHub Actions 定时运行。频率待定。

## 测试内容

* dApp 中最相关的用户交互（物品发布、NFT 购买等）

## 如何测试

我们的所有测试都必须遵循以下半结构化风格： **给定-当-那么** （GWT）。

以下示例：

1. **给定** 某用户访问 `https://example.cypress.io`
2. **当** 他们点击标注为 `类型`
3. 并将 "<fake@email.com>" 输入到 `[data-testid="action-email"]` 输入框
4. **然后** URL 应包含 `/commands/actions`
5. 并且 `[data-testid="action-email"]` 输入框的值为 "<fake@email.com>"

应写为：

```jsx
describe('给定用户访问 https://example.cypress.io', () => {
  beforeEach(() => {
    cy.visit('https://example.cypress.io')
  })

  describe('当点击标注为 type 的链接时', () => {
    beforeEach(() => {
      cy.contains('type').click()
    })

    describe('并在 action-email 输入框中输入电子邮件', () => {
      beforeEach(() => {
        // 获取一个输入框并向其中输入
        cy.get('.action-email').type('fake@email.com')
      })

      it('那么 URL 应包含 /commands/actions', () => {
        // 应位于一个新的 URL，该 URL
        // 包含 '/commands/actions'
        cy.url().should('include', '/commands/actions')
      })

      it('并且 action-email 输入框的值应包含输入的电子邮件', () => {
        // 验证该值已更新
        cy.get('.action-email').should('have.value', 'fake@email.com')
      })
    })
  })
})
```

## 合约测试

关于智能合约测试，请参阅 Solidity Standards 文档。


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
