我想使用 KarmaJS (0.9.2) 运行我的 Jasmine e2e 测试。我在 Windows 7 上将 Google Closure 与 AngularJS (1.0.7) 结合使用。当我使用 karma start config\karma-e2e.js
启动 karma 时,一切正常(浏览器导航到正确的页面)但它没有t 执行我的测试(在“浏览器导航到”时停止)。
config\karma-e2e.js
文件:
basePath = '../';
frameworks = ['ng-scenario'];
files = [
'tests/e2e/**/*.js'
];
autoWatch = true;
singleRun = false;
browsers = ['Chrome'];
urlRoot = '/__karma/';
proxies = {
'/': 'http://localhost:8080/'
}
plugins = [
'karma-ng-scenario'
'karma-chrome-launcher'
]
测试源(tests\e2e\scenarios.coffee
)是:
describe 'Intro page view', ->
it 'has hello world message', ->
browser().navigateTo '/app/client/'
expect(element('#text').text()).toBe 'Hello World'
我正在使用 html5Mode 路由,angular 是使用 angular.bootstrap
手动引导的,我所有的 CoffeeScript 都是由 IDE 编译的,我在浏览器控制台或命令行中没有看到任何错误。那我应该怎么做呢?我做错了什么吗?
谢谢!
最佳答案
我解决了这个问题。似乎 Angular 场景需要 ng-app 指令,这至少很奇怪(或者它是一个错误)。所以我在索引页面上调用 App.bootstrap() 后将 ng-app 属性添加到 body 中。现在一切正常。
<script type="text/javascript">
App.bootstrap();
document.body.setAttribute('ng-app', 'App');
</script>
关于testing - Angular : Running e2e tests using Karma,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16754123/