将 gitlab 中的 puppeteer 与 gitlab-ci.yml 集成 [英] integrate puppeteer in gitlab with gitlab-ci.yml

查看:18
本文介绍了将 gitlab 中的 puppeteer 与 gitlab-ci.yml 集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在 Chrome Puppeteer 中进行 e2e 测试.我正处于将我的测试集成到开发过程中的理想阶段.

Im currently working on e2e test in Chrome Puppeteer. I am at the stage where it would be ideal to integrate my tests in the development process.

我想要完成的是:我的测试在每次部署到生产之前自动运行.如果他们成功部署通过,如果他们失败部署被取消.

What I want to accomplish is the following: my tests run automated before every deploy to production. If they succeed deployment goes through, if they fail deployment is canceled.

我在 gitlab 上使用管道来自动化我的部署过程.所以我的主要问题是如何将我的 puppeteer 测试集成到 gitlab-ci.yml 文件中?

I use a pipeline on gitlab to automate my deployment process. So my main question is how can I integrate my puppeteer tests into the gitlab-ci.yml file?

推荐答案

这可能有点小技巧,但我的运行是这样的:

This might be a bit of a hack but mine are running like this:

test:
image: node:latest
stage: run
script:
- apt-get update
- apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
- yarn
- yarn test

那超长的库列表是 puppeteer 启动 chrome 所需的库.理想情况下,你会有一个现成的 docker 镜像,但我发现的所有预制镜像都不适合我.

That super long list of libraries are the ones that the puppeteer needs to launch chrome. Ideally you would have a ready docker image but all the premade ones I found did not work for me.

当为 prod 做好准备时,您应该构建自己的映像,该映像从节点获取并自行安装依赖项.

When getting ready for prod you should build your own image that takes from node and installs the dependencies itself.

这篇关于将 gitlab 中的 puppeteer 与 gitlab-ci.yml 集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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