【问题标题】:Bitbucket pipeline Your system is missing the dependency: XvfbBitbucket 管道您的系统缺少依赖项:Xvfb
【发布时间】:2021-05-28 02:21:43
【问题描述】:

我正在尝试将 cypress 添加到 bitbucket 管道,但它告诉我需要安装 Xvfb,但我不知道如何继续。这是我的 bitbucket.pipelines.yml

#  Template NodeJS build

#  This template allows you to validate your NodeJS code.
#  The workflow allows running tests and code linting on the default branch.

image: node:14.15.4

pipelines:
  default:
    - step:
        name: Build
        script:
          - npm install
          - npm run lint
          - npm run cypress:run

这是我的 package.json 脚本

"scripts": {
    "cypress:open": "cypress open",
    "cypress:run": "npx cypress run --record --key xxxxxxxxxxxx"
}

并且测试在本地运行良好

但是在管道中我收到了这个错误:

+ npm run cypress:run
> wallet-frontend@0.1.0 cypress:run /opt/atlassian/pipelines/agent/build
> npx cypress run --record --key 70004462-62d4-42ce-b359-5bff73d8b001
It looks like this is your first time using Cypress: 6.5.0
[16:30:09]  Verifying Cypress can run /root/.cache/Cypress/6.5.0/Cypress [started]
[16:30:09]  Verifying Cypress can run /root/.cache/Cypress/6.5.0/Cypress [failed]
Your system is missing the dependency: Xvfb
Install Xvfb and run Cypress again.
Read our documentation on dependencies for more information:
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Error: spawn Xvfb ENOENT
----------
Platform: linux (Debian - 9.13)
Cypress Version: 6.5.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wallet-frontend@0.1.0 cypress:run: `npx cypress run --record --key xxxxxxxxx`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the wallet-frontend@0.1.0 cypress:run script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

【问题讨论】:

标签: testing npm bitbucket cypress


【解决方案1】:

Xvfb 是一个内存显示服务器,适用于类 UNIX 操作系统,在您的情况下是 Linux (Debian - 9.13)。这是 cypress 假设预先安装的系统级依赖项。在 bitbucket env 的情况下,它未安装,因此出现此错误。这主要用于在运行 cypress 时在有头浏览器的情况下显示 (UI)。

这里有几个简单的解决方法:

  1. 手动安装依赖项:我不建议这样做,因为除非您彻底检查所有依赖项,否则您可能会错过更多的依赖项。

  2. 运行无头浏览器::无头浏览器不使用 Xvfb,因此不会遇到这个确切的错误,但正如我在第 1 点中所说,可能还有其他问题。命令将变为cypress run --headless

  3. 使用赛普拉斯提供的 Docker 映像(建议):我可以看到您在此构建中使用 node:14.15.4 映像。取而代之的是,使用柏树提供的官方base images 来运行您要运行的任何节点版本(在tags 中查找不同的节点版本)。如果你查看Dockerfile,你会发现他们已经努力安装在 docker 中运行 Cypress 所需的依赖项(你可以在那里看到 Xvfb)。

此外,当您遇到与 cypress 相关的问题时,请查找已经打开的问题,它们有一个非常活跃且有用的问题部分。我在那里发现了同样的问题:https://github.com/cypress-io/cypress/issues/14457

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-02
    • 1970-01-01
    • 2021-11-23
    • 2018-03-12
    • 1970-01-01
    • 2016-11-29
    • 2017-12-25
    • 2015-04-18
    相关资源
    最近更新 更多