For AI agents: the complete documentation index is available at https://rstest.rs/zh/llms.txt, the full documentation bundle is available at https://rstest.rs/zh/llms-full.txt, and this page is available as Markdown at https://rstest.rs/zh/config/test/test-timeout.md.
close
  • 简体中文
  • testTimeout

    • 类型: number
    • 默认值: 5_000(Browser Mode 下为 15_000)
    • CLI: --testTimeout=5000

    单个测试用例允许运行的最长时间(毫秒),超时会直接报错失败。设为 0 表示禁用超时。

    CLI
    rstest.config.ts
    npx rstest --testTimeout=5000

    Rstest 按以下优先级(从高到低)确定测试超时时间:

    1. 单个测试通过 TestOptions.timeout 或 test 末尾参数传入的 timeout
    2. 外层 describe 套件通过 TestOptions.timeout 设置的超时时间(就近优先)
    3. 测试文件中通过 rs.setConfig({ testTimeout }) 设置的超时时间
    4. CLI 的 --testTimeout 选项或 run({ testTimeout })
    5. 配置文件中的 testTimeout 选项
    6. 默认值 5_000 毫秒(Browser Mode 下为 15_000 毫秒)

    Browser Mode 下 expect.poll.timeout 的默认值也为 5_000 毫秒,Node Mode 下为 1_000 毫秒;详见 expect.poll。