跳到主要内容

TestResult

单个 TestCase 运行的结果。


属性

附件

添加于版本: v1.10 testResult.attachments

在测试执行期间通过 testInfo.attachments 附加的文件或缓冲区列表。

用法

testResult.attachments

类型

  • Array<Object>
    • name string

      附件名称。

    • contentType string

      此附件的内容类型,以便在报告中正确显示,例如 'application/json''image/png'

    • path string (可选)

      文件系统上附加文件的可选路径。

    • body Buffer (可选)

      可选的附件主体,用于代替文件。


duration

添加于版本: v1.10 testResult.duration

运行时间,以毫秒为单位。

用法

testResult.duration

类型


error

添加于版本: v1.10 testResult.error

测试执行期间抛出的第一个错误(如果有)。这等于 testResult.errors 中的第一个元素。

用法

testResult.error

类型


errors

添加于版本: v1.10 testResult.errors

测试执行期间抛出的错误。

用法

testResult.errors

类型


parallelIndex

添加于版本: v1.30 testResult.parallelIndex

worker 的索引,介于 0workers - 1 之间。保证同时运行的 worker 具有不同的 parallelIndex

用法

testResult.parallelIndex

类型


retry

添加于版本: v1.10 testResult.retry

当测试多次重试时,每次重试尝试都会被赋予一个连续的编号。

了解更多关于 测试重试 的信息。

用法

testResult.retry

类型


startTime

添加于版本: v1.10 testResult.startTime

此特定测试运行的开始时间。

用法

testResult.startTime

类型


status

添加于版本: v1.10 testResult.status

此测试结果的状态。另请参阅 testCase.expectedStatus

用法

testResult.status

类型

  • "passed" | "failed" | "timedOut" | "skipped" | "interrupted"

stderr

添加于版本: v1.10 testResult.stderr

测试运行期间写入标准错误流的任何内容。

用法

testResult.stderr

类型


stdout

添加于版本: v1.10 testResult.stdout

测试运行期间写入标准输出流的任何内容。

用法

testResult.stdout

类型


steps

添加于版本: v1.10 testResult.steps

此测试运行内部步骤的列表。

用法

testResult.steps

类型


workerIndex

添加于版本: v1.10 testResult.workerIndex

运行测试的 worker 的索引。如果测试没有单次运行(例如,当用户中断测试时),则唯一的结果将具有等于 -1workerIndex

了解更多关于 Playwright Test 的 并行和分片 的信息。

用法

testResult.workerIndex

类型