> For the complete documentation index, see [llms.txt](https://easonwang.gitbook.io/web_advance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://easonwang.gitbook.io/web_advance/react-native/zi-dong-hua-ce-shi.md).

# 自動化測試

使用 Dexon

<https://github.com/wix/Detox/tree/master/docs>

搭配 Jest

{% embed url="<https://github.com/wix/Detox/blob/master/docs/Guide.Jest.md>" %}

```
yarn add jest jest-circus detox --dev
npx detox init -r jest
```

之後會出現四個檔案

1. detoxrc.json
2. e2e/config.json
3. e2e/enviroment.js
4. firstTest.e2e.js

於 Android 目錄下輸入 `./gradlew assembleDebug`

然後去修改 .detoxrc.json 中的 binarypath 與 avdName 類似如下

```
    "android": {
      "type": "android.emulator",
      "binaryPath": "/Users/easonwang/MySampleApp/android/app/build/outputs/apk/debug/app-debug.apk",
      "device": {
        "avdName": "Pixel_XL_API_30"
      }
    }
```

> 但目前 React Native 0.63 還是無法執行，會有 timeout 情況\
> <https://stackoverflow.com/questions/61050417/detoxruntimeerror-failed-to-run-application-on-the-device-android>

```
npx detox test -c android
```

## Android 記得去設定 emulator

<https://github.com/wix/Detox/blob/master/docs/Introduction.AndroidDevEnv.md>


---

# 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://easonwang.gitbook.io/web_advance/react-native/zi-dong-hua-ce-shi.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.
