跳到主要內容

TestResult

單次 TestCase 執行的結果。


屬性

attachments

新增於: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 的索引。如果測試不是單次執行(例如,當使用者中斷測試時),則唯一結果的 workerIndex 將等於 -1

深入了解 Playwright Test 的平行處理和分片

用法

testResult.workerIndex

類型