Bitbucket管道您的系统缺少依赖项:xvfb [英] Bitbucket pipeline Your system is missing the dependency: Xvfb

查看:38
本文介绍了Bitbucket管道您的系统缺少依赖项:xvfb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试将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.

xvfb

xvfb是用于类推荐答案操作系统的内存显示服务器,在您的例子中是linux(debian-9.13)。这是一个系统级的依赖项,Cypress假定预先安装了该依赖项。对于Bitbucket env,它没有安装,因此出现此错误。这主要用于在运行cypress时显示(UI)有标题的浏览器。

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

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

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

  3. 使用Cypress提供的Docker镜像(建议):我可以看到您使用的是此版本的node:14.15.4镜像。相反,对于您想要运行任何节点版本,可以使用官方提供的Cypressbase images(在tags中查找不同的节点版本)。如果您查看Dockerfile,您会发现他们已经努力在docker中安装运行Cypress所需的依赖项(您可以在那里看到Xvfb)。

此外,当您陷入与柏树相关的问题时,请寻找已经打开的问题,它们有一个非常活跃和有帮助的问题部分。我在那里发现了同样的问题:https://github.com/cypress-io/cypress/issues/14457

这篇关于Bitbucket管道您的系统缺少依赖项:xvfb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆