【问题标题】:How to setup codecept e2e testing with angular2?如何使用 angular2 设置 codecept e2e 测试?
【发布时间】:2017-03-03 13:16:03
【问题描述】:

我是 e2e 测试的新手。我想试试http://codecept.io/angular/

自从我使用https://github.com/AngularClass/angular2-webpack-starter Protractor/Jasmine 开始我的应用程序以来,它已经在工作了。

据我了解,codecept 是在量角器之上工作的。 我已经正确安装了它,但是当我启动一个简单的测试时,我遇到了一个失败的错误。

这是我的 codecept.json:

{
  "tests": "src/app/*_test.js",
  "timeout": 10000,
  "output": "./output",
  "helpers": {
    "Protractor": {
      "url": "http://localhost:3000/",
      "driver": "hosted",
      "browser": "chrome",
      "rootElement": "body"
    }
  },
  "include": {
    "I": "./steps_file.js"
  },
  "bootstrap": false,
  "mocha": {},
  "name": "front"
}

这是我的测试:

Feature('MyApp');

Scenario('First Test', (I) => {
  I.amOnPage('/#/home');
});

这是错误日志:

MyApp --
 First Test
 • I am on page "/#/home"
 ✖ FAILED in undefinedms

 ✖ "after each" hook: finialize codeceptjs in 0ms

-- FAILURES:

  1) MyApp: First Test:
     Uncaught Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444

有什么帮助吗?

【问题讨论】:

    标签: angular codeceptjs


    【解决方案1】:

    在这里回答Unable to run Protractor - ECONNREFUSED connect ECONNREFUSED

    webdriver-manager update
    
    webdriver-manager start --standalone
    

    这是我的 codecept.json:

    {
      "tests": "src/app/*_test.js",
      "timeout": 10000,
      "output": "./output",
      "helpers": {
        "Protractor": {
          "url": "http://localhost:3000/",
          "driver": "hosted",
          "browser": "chrome",
          "rootElement": "body",
          "useAllAngular2AppRoots": true
        }
      },
      "include": {
        "I": "./steps_file.js"
      },
      "bootstrap": false,
      "mocha": {},
      "name": "front"
    }
    

    注意“useAllAngular2AppRoots”:true

    【讨论】:

    • 你成功使用CodeCept了吗,为什么我还需要手动启动Webdriver。
    【解决方案2】:

    您可以在直接模式下运行 Protractor - 这会跳过 webdriver/selenium 服务器并将 Protractor 助手直接连接到浏览器。

    您需要使用“直接”模式配置 Protractor,如下所示: 'directConnect' 值被传递给 Protractor 本身,因此它也使用直接模式。

    "helpers": {
      "Protractor": {
        "url": "http://localhost:3000/",
        "driver": "direct", 
        "directConnect": true, 
        "browser": "chrome",
        "rootElement": "body",
        "useAllAngular2AppRoots": true
      }  
    },
    

    【讨论】:

      猜你喜欢
      • 2018-05-12
      • 1970-01-01
      • 2016-05-05
      • 2021-05-10
      • 1970-01-01
      • 1970-01-01
      • 2016-02-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多