0

为什么我会收到此错误:Selector [ng\:model="query"] did not match any elements

我已经阅读了这个:AngularJS: End to End Testing Issue,但该链接并不真正适用于.net env:

IDE:Visual Studio 2012
项目类型:ASP.NET MVC4
文件结构:
文件夹结构

在 node.js 命令提示符下通过 karma start e2e.conf.js 运行 CI 测试

我的因果报应:

basePath = '../../../';

files = [
  ANGULAR_SCENARIO,
  ANGULAR_SCENARIO_ADAPTER,
  'angular/app/*.js',
  'angular/Tests/e2e/*.js'
];

reporters = ['progress'];

port = 10876;

runnerPort = 10100;

colors = true;

logLevel = LOG_ERROR;

autoWatch = true;

browsers = ['Firefox'];

captureTimeout = 60000;

singleRun = false;

proxies = {
    '/': 'http://localhost:60607/'
};

我的 e2e 测试:

describe('E2E: AMS', function () {

    describe('Settings Users', function () {

        beforeEach(function () {
            browser().navigateTo('/#/settings/users');
        });


        it('filters the users list as the user types into the search box', function () {
            expect(repeater('.users li').count()).toBe(2);

            input('query').enter('abc');
            expect(repeater('.users li').count()).toBe(1);

            input('query').enter('efg');
            expect(repeater('.users li').count()).toBe(1);

            input('query').enter('ijk');
            expect(repeater('.users li').count()).toBe(0);
        });
    });
});

我的观点:

<div data-ng-view="">

Add User: <br />
<input type="text" /> <button>Submit</button><br />

Search:
<input data-ng-model="query" type="text" />

Users <br />
<ul class="users">
    <li data-ng-repeat="user in users | filter:query">
        {{user.name}}
    </li>
</ul>

</div>

我的路线

angular.module('AMS', []).
  config(['$routeProvider', function ($routeProvider) {
      $routeProvider.
          when('/login', { templateUrl: '/AccessControl/Login/', controller: settingsController }).
          when('/dashboard', { templateUrl: '/Dashboard/Dashboard', controller: dashboardController }).
          when('/settings', { templateUrl: '/Settings/Settings', controller: settingsController }).
          when('/settings/users', { templateUrl: '/Settings/Users', controller: settingsController }).
          otherwise({ redirectTo: '/dashboard' });
  }]);
4

2 回答 2

0

看起来角度 e2e 测试 api 正在您的视图中寻找“ng-model”,而不是您正在使用的“data-ng-model”。

我的理解是两者都是有效的,但请尝试看看这是否是问题所在。

于 2013-05-14T01:36:57.700 回答
0

不是答案,所以我不会这样标记它,这更像是一种解决方法。

我决定使用 chutzpah 来运行 jasmine 单元测试,并使用 specflow.xunit 进行“e2e”测试。它在 .net 环境中运行良好,并且集成到 teamcity 似乎很简单。

于 2013-05-20T15:06:58.840 回答