Playwright无法识别运行中Angular服务器的问题及解决方法
Angular + Playwright 测试启动超时问题解决方案
问题描述
运行Playwright测试时,无法识别http://localhost:4200上已启动的Angular应用,进而触发服务器重启流程,最终因启动超时失败。该问题在M2 MacBook上较为常见,推测与设备的网络/终端处理机制相关。
原问题配置
webServer: [ { command: 'nx serve', url: 'http://localhost:4200/', // 问题所在 timeout: 600 * 1000, reuseExistingServer: true, }, ],
解决方案
将配置中的url字段替换为port字段,指定端口号即可解决问题。
修改后的正确配置
webServer: [ { command: 'nx serve', port: 4200, // 修改后 timeout: 600 * 1000, reuseExistingServer: true, }, ],
内容的提问来源于stack exchange,提问作者Roman Hoshovskij
相关产品推荐
相关产品推荐

