为什么我收到此错误:Selector [ng\:model="query"] did not match any elements
我已经读过这个:AngularJS: End to End Testing Issue,但该链接并不真正适用于.net环境:
IDE:Visual Studio 2012
项目类型:ASP.NET MVC4
档案结构:
通过karma运行CI测试会在node.js命令提示符下启动e2e.conf.js
我的业力骗局:
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' });
}]);
答案 0 :(得分:0)
看起来角度e2e测试api正在您的视图中寻找“ng-model”而不是您正在使用的“data-ng-model”。
我的理解是两者都是有效的,但试着看看这是不是问题。
答案 1 :(得分:0)
不是答案,所以我不会这样做,这更像是一种解决方法。
我决定使用chutzpah运行茉莉花单元测试,并使用specflow.xunit进行“e2e”测试。它在.net环境中运行良好,并且可以直接集成到teamcity中。