使用testacular的Angularjs e2e测试会断开所有浏览器的连接

时间:2013-04-03 22:51:27

标签: angularjs karma-runner

我试图使用testacular在我的AngularJs项目上进行e2e测试。我成功启动了一个基于node.js的Web服务器,我可以看到在加载URL时如何发送文件,即使我可以在我的浏览器上看到视觉结果但是Testacular测试不起作用。我收到这个错误:

[2013-04-04 00:31:00.499] [WARN] config - "/" is proxied, you should probably change urlRoot to avoid conflicts
INFO [testacular]: Testacular server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [launcher]: Starting browser Firefox
INFO [Chrome 26.0 (Mac)]: Connected on socket id EN7sZuseiLuwlddbBkqn
INFO [Firefox 13.0 (Mac)]: Connected on socket id lBTUcn8b75p5O_cPBkqo
Chrome 26.0 (Mac): Executed 0 of 3
Chrome 26.0 (Mac): Executed 0 of 3 DISCONNECTED (0.413 secs / 0 secs)
Firefox 13.0 (Mac): Executed 0 of 3 DISCONNECTED (0.31 secs / 0 secs)
WARN [Chrome 26.0 (Mac)]: Disconnected

这是我的testacular配置文件:

basePath = '../';

files = [
  ANGULAR_SCENARIO,
  ANGULAR_SCENARIO_ADAPTER,
  'test/e2e/**/*.js'
];

autoWatch = true;
browsers = ['Chrome', 'Firefox'];
singleRun = false;

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

junitReporter = {
  outputFile: 'test_out/e2e.xml',
  suite: 'e2e'
};

关于我在做什么的任何想法?

1 个答案:

答案 0 :(得分:1)

我遇到了类似的问题。我使用的是index.html asynch风格,结果证明您还需要将ng-app放在document.body中。

angular.bootstrap(document, ['app']);

document.body.className = document.body.className + ' ng-app';

参考:https://github.com/karma-runner/karma/issues/422