跳转到主要内容

TestStep

表示 [TestRun] 中的一个步骤。


方法

titlePath

新增于: v1.10 testStep.titlePath

返回从根步骤到此步骤的步骤标题列表。

用法

testStep.titlePath();

返回


属性

annotations

添加于: v1.51 testStep.annotations

适用于当前测试步骤的注释列表。

用法

testStep.annotations

类型


attachments

新增于: v1.50 testStep.attachments

通过 testInfo.attach() 在步骤执行中附加的文件或缓冲区列表。

用法

testStep.attachments

类型

  • Array<Object>
    • name string

      附件名称。

    • contentType string

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

    • path string (可选)

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

    • body Buffer (可选)

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


category

新增于: v1.10 testStep.category

步骤类别,用于区分不同来源和详细程度的步骤。内置类别包括

  • expect 用于 expect 调用
  • fixture 用于夹具设置和拆卸
  • hook 用于钩子初始化和拆卸
  • pw:api 用于 Playwright API 调用。
  • test.step 用于 test.step API 调用。
  • test.attach 用于 test attachmen 调用。

用法

testStep.category

类型


duration

新增于: v1.10 testStep.duration

运行时间(毫秒)。

用法

testStep.duration

类型


error

新增于: v1.10 testStep.error

步骤执行过程中抛出的错误(如果有)。

用法

testStep.error

类型


location

新增于: v1.10 testStep.location

定义步骤的源代码中的可选位置。

用法

testStep.location

类型


parent

新增于: v1.10 testStep.parent

父步骤(如果有)。

用法

testStep.parent

类型


startTime

新增于: v1.10 testStep.startTime

此特定测试步骤的开始时间。

用法

testStep.startTime

类型


steps

新增于: v1.10 testStep.steps

此步骤中的步骤列表。

用法

testStep.steps

类型


title

新增于: v1.10 testStep.title

用户友好的测试步骤标题。

用法

testStep.title

类型