如何使用 GitLab CI 设置 Selenium E2E 测试? [英] How to setup Selenium E2E testing with GitLab CI?

查看:65
本文介绍了如何使用 GitLab CI 设置 Selenium E2E 测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为网站前端开发 Vue.js 应用.

I am developing a Vue.js app for a website frontend.

对于这个应用程序,我想使用单元测试和 E2E 测试.我用 vue-cli 构建了我的项目.

For this app I would like to use Unit and E2E tests. I built my project with vue-cli.

据我了解,vue-cli 使用 Karma 进行单元测试,使用 Nightwatch + Selenium 进行 E2E 测试.

From my understanding, vue-cli uses Karma for unit tests and Nightwatch + Selenium for E2E tests.

我的 .gitlab-ci.yml 如下所示:

stages:
  - test

test:express:
  image: node:boron
  stage: test
  script:
    - cd backend/
    - npm install --progress=false
    - ./node_modules/.bin/jasmine

test:vue:
  image: node:boron
  stage: test
  script:
    - cd frontend/
    - npm install --progress=false
    - npm test

npm test 运行 e2e 和单元测试并在本地计算机上运行.单元测试运行顺利,Selenium 会弹出一个 Chrome 窗口并使用 E2E 测试.

npm test runs e2e and unit tests and works on local computers. The Unit tests run smoothly and the Selenium brings up a Chrome window and uses the E2E tests.

问题是不知道如何在 GitLab CI 上运行 E2E Selenium 测试.它一直给我一个错误说:

The problem is that don't know how to run E2E Selenium tests on GitLab CI. It keeps giving me an error saying:

无法连接到 Selenium 服务器.你启动了Selenium Server了吗?,虽然前面说了两行已经创建了Selenium Server.

Could not connect to Selenium Server. Have you started the Selenium Server yet?, although it says two lines before that it has already created a Selenium server.

如何在 GitLab CI 上运行 E2E Selenium 测试?如果这无法实现,我可以在 GitLab CI 上运行什么样的 E2E?

How can I run E2E Selenium tests on GitLab CI? If this is not achievable, what kind of E2E can I run on GitLab CI?

推荐答案

你必须自己将 Selenium 带到你的管道中才能使用它.

You have to bring Selenium yourself to your pipeline in order to use it.

为此,您应该使用类似 gitlab-selenium-server 正如 repo 的 README 中所描述的那样.

To do so, you should use something like gitlab-selenium-server as it is described in the repo's README.

另一种选择是使用 GitLab CI 服务,如 这篇博文.

Another option is to use a GitLab CI service as described in this blog post.

这篇关于如何使用 GitLab CI 设置 Selenium E2E 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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