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

Azure DevOps Pipeline中Playwright测试失败后挂起问题求助

Azure DevOps Playwright测试失败后Pipeline挂起的解决办法

我在Azure DevOps中配置了一个运行Playwright测试的Pipeline,特意设置其中一个测试用例为失败状态,结果发现测试失败后Pipeline直接挂起——我等了30分钟后手动取消了任务,推测最终会触发超时;但所有测试都成功时,Pipeline能正常退出。

解决方法

在playwright.config.ts文件中添加报告器配置,禁用测试失败时自动打开HTML报告:

reporter: [ ['html', { open: 'never' }] ],

问题根源是Playwright默认配置会在测试失败时自动打开HTML报告,而Azure DevOps的虚拟机环境没有图形界面支持,导致进程无法正常退出,进而卡住Pipeline。可根据需求选择合适的报告器类型。

原Azure DevOps Pipeline YAML配置

trigger:
   - master
   - test
   - dev

pool:
   vmImage: macos-latest

jobs:
   - job: Build
     displayName: Build stage
     steps:
        - task: NodeTool@0
          inputs:
             versionSpec: '16.x'
          displayName: 'Install Node.js'
        - script: |
                npm ci
          displayName: 'Install dependencies'
        - script: |
            npx playwright install --with-deps
          displayName: 'Install Playwright'
        - script: |
            npm run test-unit-smoke
          displayName: 'Run unit tests'

内容的提问来源于stack exchange,提问作者ChunkyHippo

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 10:50:24