Skip to main content

TestStep

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

🌐 Represents a step in the [TestRun].


方法

🌐 Methods

titlePath

Added in: v1.10 testStep.titlePath

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

🌐 Returns a list of step titles from the root step down to this step.

用法

testStep.titlePath();

返回


属性

🌐 Properties

annotations

Added in: v1.51 testStep.annotations

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

🌐 The list of annotations applicable to the current test step.

用法

testStep.annotations

类型

  • [数组]<[对象]>
    • type string

      注释类型,例如 'skip'

    • description string (optional)

      可选描述。

    • location Location (optional)

      源代码中添加注释的可选位置。


attachments

Added in: v1.50 testStep.attachments

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

🌐 The list of files or buffers attached in the step execution through testInfo.attach().

用法

testStep.attachments

类型

  • [数组]<[对象]>
    • name string

      附件名称。

    • contentType string

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

    • path string (optional)

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

    • body Buffer (optional)

      使用可选附件正文代替文件。


category

Added in: v1.10 testStep.category

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

🌐 Step category to differentiate steps with different origin and verbosity. Built-in categories are:

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

用法

testStep.category

类型


duration

Added in: v1.10 testStep.duration

运行时间以毫秒为单位。

🌐 Running time in milliseconds.

用法

testStep.duration

类型


error

Added in: v1.10 testStep.error

步骤执行期间抛出的错误(如果有)。

🌐 Error thrown during the step execution, if any.

用法

testStep.error

类型


location

Added in: v1.10 testStep.location

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

🌐 Optional location in the source where the step is defined.

用法

testStep.location

类型


parent

Added in: v1.10 testStep.parent

父步骤(如果有)。

🌐 Parent step, if any.

用法

testStep.parent

类型


startTime

Added in: v1.10 testStep.startTime

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

🌐 Start time of this particular test step.

用法

testStep.startTime

类型


steps

Added in: v1.10 testStep.steps

此步骤内的步骤列表。

🌐 List of steps inside this step.

用法

testStep.steps

类型

  • [数组]<[测试步骤]>

title

Added in: v1.10 testStep.title

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

🌐 User-friendly test step title.

用法

testStep.title

类型