我已经尝试了几个安装了 google-chrome 的可用 docker 容器。尝试以 headless 模式运行它。一些尝试过的图像是:
selenium/standalone-chrome
zenika/alpine-chrome
已安装 nvm 和所有必要的包
When running the commands to start test or build, it simply gets stuck forever.
npm test
或
npm run build
这是testee.json中的配置
{
"port": 3621,
"root": ".",
"reporter": "Spec",
"timeout": 120,
"delay": 1000,
"tunnel": {
"type": "local"
},
"launch": {
"type": "local"
},
"browsers": [{
"browser": "chrome",
"args": [
"--headless",
"--disable-gpu",
"--remote-debugging-port=9222"
]
}]
}
最佳答案
您需要在浏览器中添加“--no-sandbox”-> testee.json 中的 args 对象
{
"port": 3621,
"root": ".",
"reporter": "Spec",
"timeout": 120,
"delay": 1000,
"tunnel": {
"type": "local"
},
"launch": {
"type": "local"
},
"browsers": [{
"browser": "chrome",
"args": [
"--headless",
"--no-sandbox',
"--disable-gpu",
"--remote-debugging-port=9222"
]
}]
}
更多信息Click here
关于javascript - 无法在 Docker 容器内运行 JavaScript 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52025684/