next.js 编剧Vercel错误:browserType.launch:/home/sbx_user1051/.cache/ms-playwright/chromium-1067/chrome-linux/chrome中不存在可执行文件

b1payxdu  于 2023-10-18  发布在  Linux
关注(0)|答案(1)|浏览(116)

我尝试并测试了不同的本地环境,如Windows,Linux,Mac和任何地方,它都工作正常,但一旦我在Vercel上部署我的nextjs应用程序,我得到下面的错误

browserType.launch: Executable doesn't exist at /home/sbx_user1051/.cache/ms-playwright/chromium-1067/chrome-linux/chrome
╔═════════════════════════════════════════════════════════════════════════╗
║ Looks like Playwright Test or Playwright was just installed or updated. ║
║ Please run the following command to download new browsers:              ║
║                                                                         ║
║     npx playwright install                                              ║
║                                                                         ║
║ <3 Playwright Team                                                      ║
╚═════════════════════════════════════════════════════════════════════════╝
    at pdf (/var/task/.next/server/pages/api/jobOrders/pdf.js:58:80)
    at pdfHandler (/var/task/.next/server/pages/api/jobOrders/pdf.js:91:31) {
  name: 'Error'
}

为了解决此问题,我尝试将Vercel部署设置中的build命令修改为

next build && npx playwright install


虽然我看到像Chrome和Firefox这样的浏览器成功安装,但我仍然想知道为什么我会得到这个错误。

lndjwyie

lndjwyie1#

通常,在CI阶段,您应该在部署应用程序之前运行测试。只有在成功完成所有测试后,才应继续进行生产部署。
但是,您可以在完成Vercel部署后,将Vercel的webhooks与Git提供程序配合使用,以运行端到端测试套件。本示例将使用GitHub操作。

配置GitHub Action

1.将Git仓库连接到项目。对于新项目,您可以遵循这些文档。对于现有项目,请在项目控制面板的Settings选项卡中访问您的Git配置。
1.在.github/workflows中创建一个GitHub工作流,如下所示:

name: Playwright Tests

on:
  deployment_status:
jobs:
  run-e2es:
    if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install dependencies
        run: npx playwright install --with-deps
      - name: Run tests
        run: npx playwright test
        env:
          BASE_URL: ${{ github.event.deployment_status.environment_url }}

一个GitHub Action,使用Playwright运行端到端测试套件,测试Vercel预览部署。

相关问题