node.js - Cypress 间歇性无法验证基本 url 是否正在运行

标签 node.js node-modules e2e-testing cypress

我刚刚开始尝试 Cypress 测试框架。我在 Jenkins 作业中运行了一个简单的测试,该测试是由安装和启动服务器的上游作业启动的。它还通过在新启动的服务器上点击 URL 来运行一些单元测试,因此必须启动服务器才能成功完成并启动 cypress 测试作业。

由于某种原因,cypress 间歇性失败,因为它无法验证基本 URL 上的服务器是否正在运行。我删除了基本 url 配置,并在 cy.visit() 中使用完整的 url,到目前为止它已成功运行。

有人知道为什么 Cypress 验证基本 URL 时会间歇性失败吗?

这是我用来运行测试的代码。我正在运行 Gulp 任务:

gulp.task('run-ui-tests', function() {

return cypress.run({
      spec: './cypress/integration/main_navigation.js',
      config: {
          //baseUrl: config.urlProtocol + "://" + config.e2eTestsBaseUrl,
          viewportWidth: 1200,
          viewportHeight: 660,
          videoRecording: false,
          toConsole: false
      },
      reporter: "junit",
      reporterOptions: {
            mochaFile: "cypress/results/test-output.xml",
            toConsole: false,
            rootSuiteTitle: "UI Test Suite",
            testsuitesTitle: "UI Tests"
        }
    })
    .then((results) => {
        if (results.failures === 0) {
            console.log(results.passes + " of " + results.tests + " tests passed!")
            console.log(results.failures + " tests failed!")
            console.log("Ran for " + results.duration);
        } else {
            throw new Error(results.failures + " UI tests failed!! See /cypress/results/test-output.xml for more details.");
        }
    })
    .catch((err) => {
        throw new Error(err)
    }); 
});

最佳答案

事实证明,我尝试运行测试的开发服务器没有 DNS 条目。我输入了该内容,从那时起它就一直完美地工作。

关于node.js - Cypress 间歇性无法验证基本 url 是否正在运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49062282/

相关文章:

node.js - 如何将 ExpressJS 服务器与 Angular2 集成

javascript - 如何优化 Angularjs 中实时通知的 $interval?

javascript - 修改console.log

node.js - 根据脚本内容恢复 node-modules 和 bower_components

node.js - 使用选项卡 View 可滚动属性的正确方法是什么?

javascript - node.js WebSocket 服务器

node.js - Node --experimental-modules,请求的模块不提供名为的导出

testing - 单击下载链接并应用 .wait(120000) 会引发错误

javascript - 如何将 userDataDir 配置文件文件夹传递给 Puppeteer

testing - 如何在 .testcafe 配置文件中为固定装置元设置多个过滤器?