Playwright全局Teardown项目提前执行问题求助
Playwright全局Teardown提前执行问题
严格按照Playwright文档配置全局setup和teardown项目后,teardown项目始终在实际测试前执行。我尝试给测试项目额外添加"teardown"键,问题依旧。
我使用npx playwright init生成playwright.config.ts,添加了如下配置:
projects: [ { name: 'setup', testMatch: /global\.setup\.ts/, teardown: 'teardown', }, { name: 'teardown', testMatch: /global\.teardown\.ts/, }, { name: 'chromium', use: { ...devices['Desktop Chrome'] }, dependencies: ['setup'], }, { name: 'firefox', use: { ...devices['Desktop Firefox'] }, dependencies: ['setup'], }, ]
tests/global.setup.ts内容为:
console.log("H E L L O !")
global.teardown.ts内容为输出"BYE"。
运行测试时,teardown在setup后立即执行,早于实际测试:
$ npx playwright test --project=firefox H E L L O ! B Y E Running 2 tests using 2 workers 2 passed (5.3s)
移除依赖后,setup和teardown都不会运行,符合预期。想问下有没有人按照文档示例成功让teardown在测试后执行?
内容的提问来源于stack exchange,提问作者Yves Dorfsman
相关产品推荐
相关产品推荐

