node.js - 如何在 Jenkins 中运行 Nightwatch.js 测试?

标签 node.js jenkins tfs nightwatch.js

我想使用我编写的 UI 测试来实现 CI/CD,以便每晚自动运行 Nightwatch.js 测试。我尝试将文件复制到 Jenkins 的工作区并运行它们。我尝试过使用 TFS 作为版本控制系统,看看是否可以让它以这种方式运行。我一直遇到的问题(见附件)是,当我在本地运行时,chrome 浏览器会打开并运行测试。然而,在 Jenkins 中,它说找不到该元素。我研究了如何 headless 运行 chrome,但是当我将 --headless 标签添加到 nightwatch.json 配置文件时,我仍然遇到相同的错误。底线是,如何让 Nightwatch.js 测试按每晚计划运行? (最好在 Jenkins )

尝试从 tfs 源代码管理运行测试 尝试从复制到 Jenkins 工作区的本地测试运行测试。 尝试运行 headless 测试(本地有效,Jenkins 无效)https://developers.google.com/web/updates/2017/04/headless-chrome

这是我的 nightwatch.json 文件。

{
    "src_folders" : ["tests"],
    "output_folder" : "reports/XMLReports",
    "custom_commands_path" : "",
    "custom_assertions_path" : "",
    "page_objects_path" : "dealer",
    "globals_path" : "",
    "test_workers": false,
    "selenium": {
      "cli_args": {
        "webdriver.chrome.driver" : "node_modules/.bin/chromedriver.cmd",
        "webdriver.gecko.driver" : "node_modules/.bin/geckodriver.cmd",
        "webdriver.edge.driver" : "node_modules/.bin/edgedriver.cmd"
    },
    "log_path": "",
    "port": 4460,
    "server_path": "lib/drivers/selenium-server-standalone-3.141.59.jar",
    "start_process": true
  },

    "test_settings" : {
      "chrome" : {
        "launch_url" : "http://localhost",
        "selenium_port"  : 4460,
        "selenium_host"  : "127.0.0.1",
        "silent": true,
        "screenshots" : {
          "enabled" : false,
          "path" : "screenshots/Chrome/"
        },
        "desiredCapabilities": {
          "browserName": "chrome",
          "chromeOptions":{
                "args": [
                  "disable-web-security",
                  "ignore-certificate-errors",
                  "--test-type",
                  "--disable-gpu",
                  "--headless",
                  "--remote-debugging-port=9222"
                ]
            }          
        }
      },

      "edge" : {
        "desiredCapabilities": {
          "browserName": "MicrosoftEdge"
        }
      }
    }
  }

我希望我的测试能够在 Jenkins 中正常运行,并在用户界面中通过或失败时给我一份详细的报告。 Error received from Jenkins

最佳答案

看起来 .windowMaximize() 导致我的测试在 Jenkins 中挂起并失败。

关于node.js - 如何在 Jenkins 中运行 Nightwatch.js 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55618125/

相关文章:

node.js - 在 Express js 中,如何正确结束抛出错误的流响应

shell - 如何在每个测试中重复使用预处理 jenkins/groovy

maven - Jenkins 构建参数化,可选择 Nexus Artifact 版本(所有 GAV)

javascript - 捕获 Node fs.existsSync 错误

javascript - 如何使用 Node.js 过滤掉 XML Node ?

Jenkins : Where does Jenkins store configuration files for the assigned users(ldap user)?

tfs - 在 VSTS 中执行运行功能测试任务时出错

tfs - 需要一个关于 TFS 构建过程的好的入门教程

tfs - SonarQube 排除目录名称中带有空格的目录

javascript - Nodejs Function 不是函数吗?