如何使用 Playwright 运行特定文件?

Gaj*_*ije 8 playwright playwright-test

A 将多个测试文件放入扩展名为 spec.ts 的特定文件夹中,我如何使用 Playwright 运行特定文件。当前配置设置为测试文件夹并将运行其中的所有文件(测试):

testDir: './smokeTests',

假设这是配置文件中的某个选项,但问题是哪个选项

小智 8

在配置中使用 testMatch:

testMatch:['sampleTest.spec.ts']
Run Code Online (Sandbox Code Playgroud)

https://playwright.dev/docs/api/class-testconfig#test-config-test-match

  • 另外,如果您想在配置之外运行它并作为终端命令行的一部分,您可以使用“npx playwright test sampleTest.spec.ts” (14认同)