给定以下目录结构..。
- /src/__mocks__
- X.spec.tsx <-- mock test
- Y.spec.tsx <-- mock test
- Z.spec.tsx <-- mock test
- /src/e2e_tests <-------------- only run the tests inside this directory
- X.spec.tsx <-- end-to-end test
- Y.spec.tsx <-- end-to-end test
- Z.spec.tsx <-- end-to-end test
- /src/components
- A.tsx
- A.spec.tsx <-- unit test
- B.tsx
- B.spec.tsx <-- unit test
- C.tsx
- C.spec.tsx <-- unit test
- /src/views
- X.tsx
- X.spec.tsx <-- unit test
- Y.tsx
- Y.spec.tsx <-- unit test
- Z.tsx
- Z.spec.tsx <-- unit test
- /src
- App.tsx
- index.tsx
- jest.config.ts
- playwright.config.ts
- package.json
- tsconfig.json
- tsconfig.spec.json
- ect...我尝试了以下方法:How do you specify a test folder/path with Playwright?,然而,这也将尝试运行文件夹之外的所有测试。
我尝试在这里阅读文档:https://playwright.dev/docs/test-configuration,并尝试了以下组合:
但是不能在忽略所有其他测试的同时只运行e2e_tests目录测试。
发布于 2022-07-06 16:52:25
这样做的一种方法是在现有的剧作家配置文件中创建一个项目,并在其中添加testDir,如下所示:
projects: [
{
name: 'chromium',
use: {...devices['Desktop Chrome']},
},
{
name: 'firefox',
use: {...devices['Desktop Firefox']},
},
{
name: 'webkit',
use: {...devices['Desktop Safari']},
},
{
name: 'e2e_tests',
testDir: './src/e2e_tests',
testMatch: /.*.spec.tsx/,
},
]然后运行您的测试如下:
npx playwright test --project=e2e_tests发布于 2022-07-06 17:57:33
仅仅使用剧作家命令行就可以完成这项工作。
设置您的配置以查找所有*.spec.tsx文件以进行测试和运行
npx playwright src/e2e_testshttps://stackoverflow.com/questions/72887082
复制相似问题