You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 19:33:21