Suite
Added in: v1.10Suite 是一组测试。Playwright Test 中的所有测试形成以下层次结构:
- 根套件为每个 FullProject 包含一个子套件。
- 项目套件 #1。为项目中的每个测试文件包含一个子套件。
- 文件套件 #1
- TestCase #1
- TestCase #2
- 对应
test.describe()组的套件 - < 更多测试用例 ... >
- 文件套件 #2
- < 更多文件套件 ... >
- 文件套件 #1
- 项目套件 #2
- < 更多项目套件 ... >
- 项目套件 #1。为项目中的每个测试文件包含一个子套件。
报告器在 reporter.onBegin() 方法中接收根套件。
方法
suite.allTests()
Added in: v1.10返回此套件及其后代中所有测试用例的列表,与 suite.tests 相对。
返回值
Array<TestCase>
suite.entries()
Added in: v1.44直接在此套件中定义的测试用例和套件。元素按其声明顺序返回。你可以使用 testCase.type 和 suite.type 来区分不同的条目类型。
返回值
Array<TestCase | Suite>
suite.project()
Added in: v1.10此套件所属项目的配置,对于根套件为 [void]。
返回值
FullProject | undefined
suite.titlePath()
Added in: v1.10返回从根到此套件的标题列表。
返回值
Array<string>
属性
suite.location
Added in: v1.10套件在源代码中定义的位置。根套件和项目套件没有此属性。
类型
Location
suite.parent
Added in: v1.10父套件,根套件没有此属性。
类型
Suite
suite.suites
Added in: v1.10子套件。参见 Suite 了解套件的层次结构。
类型
Array<Suite>
suite.tests
Added in: v1.10套件中的测试用例。注意只有直接在此套件中定义的测试用例在列表中。任何在嵌套的 test.describe() 组中定义的测试用例都列在子 suite.suites 中。
类型
Array<TestCase>
suite.title
Added in: v1.10套件标题。
- 根套件为空。
- 项目套件为项目名称。
- 文件套件为文件路径。
- 组套件为传递给
test.describe()的标题。
类型
string
suite.type
Added in: v1.44返回套件的类型。套件形成以下层次结构: root -> project -> file -> describe -> ...describe -> test。
类型
"root" | "project" | "file" | "describe"