跳到主要內容

TestStep

代表 [TestRun] 中的一個步驟。


方法

titlePath

Added in: v1.10 testStep.titlePath

從根步驟到此步驟,返回步驟標題的列表。

用法

testStep.titlePath();

返回


屬性

attachments

Added in: v1.50 testStep.attachments

步驟執行中透過 testInfo.attach() 附加的檔案或緩衝區列表。

用法

testStep.attachments

類型

  • Array<Object>
    • name string

      附件名稱。

    • contentType string

      此附件的內容類型,以便在報告中正確呈現,例如 'application/json''image/png'

    • path string (可選)

      附加檔案在檔案系統上的可選路徑。

    • body Buffer (可選)

      可選的附件主體,用於代替檔案。


category

Added in: v1.10 testStep.category

步驟類別,用於區分不同來源和詳細程度的步驟。內建類別包括

  • hook 用於 fixture 和 hook 的初始化和拆卸
  • expect 用於 expect 呼叫
  • pw:api 用於 Playwright API 呼叫。
  • test.step 用於 test.step API 呼叫。

用法

testStep.category

類型


duration

Added in: v1.10 testStep.duration

運行時間,以毫秒為單位。

用法

testStep.duration

類型


error

Added in: v1.10 testStep.error

步驟執行期間拋出的錯誤(如果有的話)。

用法

testStep.error

類型


location

Added in: v1.10 testStep.location

步驟定義在原始碼中的可選位置。

用法

testStep.location

類型


parent

Added in: v1.10 testStep.parent

父步驟(如果有的話)。

用法

testStep.parent

類型


startTime

Added in: v1.10 testStep.startTime

此特定測試步驟的開始時間。

用法

testStep.startTime

類型


steps

Added in: v1.10 testStep.steps

此步驟內部的步驟列表。

用法

testStep.steps

類型


title

Added in: v1.10 testStep.title

使用者友善的測試步驟標題。

用法

testStep.title

類型