跳到主要内容

TestStep

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


方法

titlePath

Added in: v1.10 testStep.titlePath

返回从根步骤到当前步骤的标题路径列表。

用法

testStep.titlePath();

返回值


属性

annotations

Added in: v1.51 testStep.annotations

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

用法

testStep.annotations

类型


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 用于夹具和钩子的初始化与清理
  • 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

添加于: v1.10 testStep.steps

该测试步骤内部包含的子步骤列表。

用法

testStep.steps

类型


title

添加于: v1.10 testStep.title

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

用法

testStep.title

类型