angularjs - Protractor 测试没有测试和断言输出,而只有规范

标签 angularjs node.js selenium protractor

我正在尝试在此处的 Protractor 网站上完成教程 https://angular.github.io/protractor/#/

但是,我的输出不包括预期的1 个测试、3 个断言、0 个失败

相反,它是:

Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Started
.


1 spec, 0 failures
Finished in 12.273 seconds
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 passed

配置文件:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['todo-spec.js']
};

测试文件:

describe('angularjs homepage todo list', function() {
  it('should add a todo', function() {
    browser.get('https://angularjs.org');

    element(by.model('todoList.todoText')).sendKeys('write first protractor test');
    element(by.css('[value="add"]')).click();

    var todoList = element.all(by.repeater('todo in todoList.todos'));
    expect(todoList.count()).toEqual(3);
    expect(todoList.get(2).getText()).toEqual('write first protractor test');

    // You wrote your first test, cross it off the list
    todoList.get(2).element(by.css('input')).click();
    var completedAmount = element.all(by.css('.done-true'));
    expect(completedAmount.count()).toEqual(2);
  });
});

版本:

  • Node 4.2.4
  • NPM 3.5.3
  • Protractor 3.0.0

最佳答案

我发现这个问题是因为 Protractor 的最新版本,v3.0.0。

我安装了 v2.5.1,现在得到 x test, x assertion, x failures 而不是 x specs, x failures

关于angularjs - Protractor 测试没有测试和断言输出,而只有规范,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34771297/

相关文章:

javascript - Angular 中的 ng-repeat 递归

javascript - AngularJS 官方网站中理解双向数据绑定(bind)教程

angularjs - 使用 Angular UI/Bootstrap UI 隐藏选项卡标题

javascript - 快速路由将 JSON 返回为 Angular 形式问题

node.js - PassportJs 身份验证无限循环和执行(默认)查询

java - 如何点击 Selenium 中网页元素的特定位置?

angularjs - Npm 测试抛出错误,但应用程序运行没有错误

node.js - Elasticsearch 6.2 - 长文本的完成建议器

javascript - 从元素 ID 获取 Json 元素值

java - 如何使用 Selenium 点击特定链接?