在 Cypress 中禁用 GPU 加速

Tom*_*DFN 15 javascript linux google-chrome node.js cypress

我在 Jenkins 的 Docker 容器中运行 Cypress。

这是我的 Dockerfile:

#Base image taken from:https://github.com/cypress-io/cypress-docker-images
FROM cypress/browsers:node14.17.0-chrome91-ff89
#Create the folder where our project will be stored
RUN mkdir /my-cypress-project
#We make it our workdirectory
WORKDIR /my-cypress-project
#Let's copy the essential files that we MUST use to run our scripts.
COPY ./package.json .
COPY ./cypress/tsconfig.json .
COPY ./cypress.config.ts .
COPY ./cypress ./cypress
RUN pwd
RUN ls
#Install the cypress dependencies in the work directory
RUN npm install
RUN npm audit fix
RUN npx cypress verify
RUN apt-get install -y xvfb
RUN google-chrome --disable-gpu --no-sandbox --headless
#Executable commands the container will use[Exec Form]
ENTRYPOINT ["npx","cypress","run"]
#With CMD in this case, we can specify more parameters to the last entrypoint.
CMD [""]    
Run Code Online (Sandbox Code Playgroud)

我是这样构建的:

docker build -t my-cypress-image:1.1.0 .
Run Code Online (Sandbox Code Playgroud)

并像这样运行:

docker run -v '$PWD':/my-cypress-project -t my-cypress-image:1.1.0 --spec cypress/e2e/pom/homeSauce.spec.js --headless --browser chrome --config-file=/my-cypress-project/cypress.config.ts
Run Code Online (Sandbox Code Playgroud)

我在控制台中收到此错误:

libva error: va_getDriverName() failed with unknown libva error,driver_name=(null)
[218:0822/100658.356057:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.
Could not find a Cypress configuration file.

We looked but did not find a cypress.config.ts file in this folder: /my-cypress-project
Run Code Online (Sandbox Code Playgroud)

现在据我所知,这是由于浏览器使用 GPU 加速运行造成的...我该如何禁用它?

我尝试将其粘贴到我的 index.js 文件中:

// cypress/plugins/index.js
module.exports = (on, config) => {
  on('before:browser:launch', (browser = {}, launchOptions) => {
    console.log(launchOptions.args)

    if (browser.name == 'chrome') {
      launchOptions.args.push('--disable-gpu')
    }

    return launchOptions
  })
}
Run Code Online (Sandbox Code Playgroud)

但我仍然得到完全相同的错误......

任何帮助,将不胜感激!干杯