我在 Jenkins 管道中运行 cypress 测试时遇到以下错误,但在本地工作正常。我应该在 Dockerfile 中设置 appData 吗?选举是否缺少写权限?
+ cypress run --browser chrome
[1m[47m[31mA JavaScript error occurred in the main process
[30mUncaught Exception:
**Error: Failed to get 'appData' path**
at App.c._setDefaultAppPaths (electron/js2c/browser_init.js:5:1300)
at Object.<anonymous> (electron/js2c/browser_init.js:185:2485)
at Object../lib/browser/init.ts (electron/js2c/browser_init.js:185:3714)
at __webpack_require__ (electron/js2c/browser_init.js:1:128)
这是 Dockerfile。
ENV CI=1
ENV QT_X11_NO_MITSHM=1
ENV _X11_NO_MITSHM=1
ENV _MITSHM=0
# should be root user
RUN echo "whoami: $(whoami)"
RUN npm config -g set user $(whoami)
# command "id" should print:
# uid=0(root) gid=0(root) groups=0(root)
# which means the current user is root
RUN id
# point Cypress at the /root/cache no matter what user account is used
ENV CYPRESS_CACHE_FOLDER=/root/.cache/Cypress
RUN npm install -g "cypress@6.3.0"
RUN cypress verify
# Cypress cache and installed version
# should be in the root user's home folder
RUN cypress cache path
RUN cypress cache list
# give every user read access to the "/root" folder where the binary is cached
# we really only need to worry about the top folder, fortunately
RUN chmod 755 /root
CMD [ "cypress", "run"]
这是詹金斯的舞台;
stage('e2e cypress testing') {
steps {
withDockerContainer(args: '-v $PWD:/e2e -w /e2e', image: '<image name>') {
// some block
sh 'cypress-run'
}
}
}
版本;
npm version: 6.14.11
Cypress package version: 6.3.0
Cypress binary version: 6.3.0
Electron version: 11.2.0
Bundled Node version: 12.18.3