首页 文章

将gitlab中的puppeteer与gitlab-ci.yml集成在一起

提问于
浏览
8

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

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

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

2 回答

  • 6

    这可能有点像黑客但我的运行方式如下:

    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
    

    超长的图书馆列表是木偶操作者需要启动Chrome的 . 理想情况下,你会有一个现成的码头图像,但我找到的所有预制的图像都不适合我 .

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

  • 5

    我们遇到了同样的问题,你需要在提供木偶操作的docker图像上运行舞台:

    # run performance monitor
    performanceMonitoring:
      stage: performanceMonitoring
      image: alekzonder/puppeteer
      script:
        - yarn run performanceMonitoring
    

相关问题