我在 app/scripts 下定义了一个相当简约的应用程序(一个控制器,三个指令)。
当 karma 运行时karma start
,我导航到 localhost:9100,单元测试运行。但是,当我运行时karma start karma-2e2.conf.js
,运行错误:
[31mChrome 27.0 (Mac) I haz all the things I haz grid FAILED[39m
TypeError: Cannot read property 'name' of undefined
Chrome 27.0 (Mac): Executed 1 of 1[31m (1 FAILED)[39m
我的测试在 test/e2e/spec/*.js 下
我的 karma-e2e.conf.js 内容如下:
basePath = '';
files = [
ANGULAR_SCENARIO,
ANGULAR_SCENARIO_ADAPTER,
'app/components/jquery/jquery.js',
'app/components/angular/angular.js',
'test/e2e/**/*.js'
];
proxies = {
'/' : 'http://localhost:9000'
}
exclude = [];
reporters = ['progress'];
port = 8080;
runnerPort = 9100;
colors = true;
logLevel = LOG_INFO;
autoWatch = false;
browsers = ['Chrome'];
captureTimeout = 5000;
singleRun = false;
我的测试是:
describe('I haz all the things', function(){
beforeEach(function(){
browser().navigateTo('/');
});
it('I haz grid', function(){
expect(angular.element('div.grid-item').count).toEqual(1);
});
});
为什么会失败,我该如何解决?