在 Docker 中运行时"The automation client disconnected. Cannot continue running tests."赛普拉斯错误



在Docker容器中运行Cypress测试套件时,我收到以下错误:

自动化客户端已断开连接。无法继续运行测试。

使用此命令,在cypress/browsers:node12.6.0-chrome75容器中运行:

cypress run --browser=chrome

这似乎是在shm空间用完时发生的。

默认情况下,Docker会创建一个/dev/shm共享内存空间为64MB的容器。这对于Chrome来说通常太小,可能会导致Chrome崩溃。

我找到了两种解决方案:

  1. 禁用/dev/shm的使用:
// cypress/plugins/index.js
module.exports = (on, config) => {
// ref: https://docs.cypress.io/api/plugins/browser-launch-api.html#Usage
on('before:browser:launch', (browser = {}, args) => {
if (browser.name === 'chrome') {
args.push('--disable-dev-shm-usage')
return args
}
return args
})
}
  1. 增加容器中/dev/shm的大小:

使用docker run --shm-size=1gb(或您想要的任何大小(运行容器

最新更新